結果
問題 |
No.407 鴨等素数間隔列の数え上げ
|
ユーザー |
![]() |
提出日時 | 2016-08-06 01:19:16 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 84 ms / 1,000 ms |
コード長 | 600 bytes |
コンパイル時間 | 180 ms |
コンパイル使用メモリ | 23,424 KB |
実行使用メモリ | 11,292 KB |
最終ジャッジ日時 | 2024-12-15 22:53:02 |
合計ジャッジ時間 | 1,658 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 31 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:21:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 21 | scanf("%Ld %Ld", &N, &L); | ~~~~~^~~~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio> using namespace std; bool x[10000010]; void sosu(int n, int l) { for (int i = 2; i <= l; i++) { if(!x[i]){ for (int j = 2; i*j <= l; j++) { x[i * j] = true; } } } /*for (int i = 2; i <= l; i++) { if(!x[i]) cout << i << " "; } cout << endl; */ } int main(void) { long long int tmp, N, L, d, round = 0, ans = 1; scanf("%Ld %Ld", &N, &L); sosu(N,L); for (int i = 2; ; i++) { if(!x[i]){ d = i; tmp = (i-1) * (N-1)+N; if(tmp > L+1) break; else tmp = L+1 - tmp + 1; round += tmp; } } printf("%Ld\n", round); //else cout << 0 << endl; return 0; }