Submission #8109887
Source Code Expand
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, B = y; i <= B; i ++)
#define ff(i, x, y) for(int i = x, B = y; i < B; i ++)
#define fd(i, x, y) for(int i = x, B = y; i >= B; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;
const int mo = 1e9 + 7;
ll ksm(ll x, ll y) {
ll s = 1;
for(; y; y /= 2, x = x * x % mo)
if(y & 1) s = s * x % mo;
return s;
}
int n;
int main() {
scanf("%d", &n);
ll ans = 0;
fo(i, 1, n) ans = (ans + ksm(ksm(3, i) * (n - i + 1) % mo, mo - 2)) % mo;
ans = ans * ksm(n, mo - 2) % mo;
pp("%lld\n", ans);
}
Submission Info
| Submission Time | |
|---|---|
| Task | F - One Third |
| User | cold_chair |
| Language | C++14 (GCC 5.4.1) |
| Score | 1800 |
| Code Size | 618 Byte |
| Status | AC |
| Exec Time | 261 ms |
| Memory | 256 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:22:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 1800 / 1800 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example0.txt, example1.txt, example2.txt, example3.txt |
| All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, example0.txt, example1.txt, example2.txt, example3.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 000.txt | AC | 1 ms | 256 KiB |
| 001.txt | AC | 1 ms | 256 KiB |
| 002.txt | AC | 1 ms | 256 KiB |
| 003.txt | AC | 1 ms | 256 KiB |
| 004.txt | AC | 1 ms | 256 KiB |
| 005.txt | AC | 1 ms | 256 KiB |
| 006.txt | AC | 261 ms | 256 KiB |
| 007.txt | AC | 261 ms | 256 KiB |
| 008.txt | AC | 261 ms | 256 KiB |
| 009.txt | AC | 261 ms | 256 KiB |
| 010.txt | AC | 261 ms | 256 KiB |
| 011.txt | AC | 261 ms | 256 KiB |
| 012.txt | AC | 261 ms | 256 KiB |
| 013.txt | AC | 261 ms | 256 KiB |
| 014.txt | AC | 261 ms | 256 KiB |
| 015.txt | AC | 261 ms | 256 KiB |
| 016.txt | AC | 251 ms | 256 KiB |
| 017.txt | AC | 238 ms | 256 KiB |
| 018.txt | AC | 246 ms | 256 KiB |
| 019.txt | AC | 256 ms | 256 KiB |
| 020.txt | AC | 248 ms | 256 KiB |
| 021.txt | AC | 1 ms | 256 KiB |
| 022.txt | AC | 1 ms | 256 KiB |
| 023.txt | AC | 1 ms | 256 KiB |
| 024.txt | AC | 1 ms | 256 KiB |
| 025.txt | AC | 1 ms | 256 KiB |
| 026.txt | AC | 1 ms | 256 KiB |
| 027.txt | AC | 1 ms | 256 KiB |
| 028.txt | AC | 2 ms | 256 KiB |
| 029.txt | AC | 3 ms | 256 KiB |
| 030.txt | AC | 4 ms | 256 KiB |
| 031.txt | AC | 7 ms | 256 KiB |
| 032.txt | AC | 13 ms | 256 KiB |
| 033.txt | AC | 33 ms | 256 KiB |
| 034.txt | AC | 49 ms | 256 KiB |
| example0.txt | AC | 1 ms | 256 KiB |
| example1.txt | AC | 1 ms | 256 KiB |
| example2.txt | AC | 1 ms | 256 KiB |
| example3.txt | AC | 261 ms | 256 KiB |