Submission #2624440
Source Code Expand
#include<cstdio> #include<iostream> using namespace std; int gcd(int x, int y) { if(x < y) return gcd(y, x); if(y == 0) return x; return gcd(y, x % y); } int nico[] = {25, 2525, 252525, 25252525};//<=10^9的所有niwango数 int main() { int N; scanf("%d", &N); int ans = 0; //容斥原理 for(int i = 1; i <= 4; i ++)//i:集合大小 { int ans0 = 0; if(i == 1) for(int j = 0; j < 4; j ++) ans0 += N / nico[j]; else { for(int j = 0; j < 5 - i; j ++)//枚举从第j个数开始的i个数(包括第j个数)组成的集合 { int tmp = 0;//从j开始的i个数的最大公约数 unsigned long long pi = 1;//从j开始的i个数的积 for(int k = j; k < i + j; k ++)//计算从j开始的i个数的最大公约数,积 { tmp = gcd(tmp, nico[k]); pi *= nico[k]; } ans0 += (unsigned long long)N / (pi / tmp); } } if(i % 2 == 1)//i是奇数 ans += ans0; else ans -= ans0; } printf("%d\n", ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - ニコニコ数 |
User | qq2964 |
Language | C++ (GCC 5.4.1) |
Score | 0 |
Code Size | 1037 Byte |
Status | WA |
Exec Time | 1 ms |
Memory | 256 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:19: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 | Subtask1 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 60 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt |
Subtask1 | sample_01.txt, sample_02.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 1 ms | 256 KB |
sample_02.txt | WA | 1 ms | 256 KB |
test_01.txt | AC | 1 ms | 256 KB |
test_02.txt | AC | 1 ms | 256 KB |
test_03.txt | AC | 1 ms | 256 KB |
test_04.txt | WA | 1 ms | 256 KB |
test_05.txt | WA | 1 ms | 256 KB |
test_06.txt | WA | 1 ms | 256 KB |
test_07.txt | WA | 1 ms | 256 KB |
test_08.txt | WA | 1 ms | 256 KB |
test_09.txt | WA | 1 ms | 256 KB |
test_10.txt | WA | 1 ms | 256 KB |
test_11.txt | WA | 1 ms | 256 KB |
test_12.txt | WA | 1 ms | 256 KB |
test_13.txt | WA | 1 ms | 256 KB |
test_14.txt | AC | 1 ms | 256 KB |
test_15.txt | AC | 1 ms | 256 KB |