結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー FF256grhy
提出日時 2016-08-05 23:09:28
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 442 bytes
コンパイル時間 421 ms
コンパイル使用メモリ 22,272 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-07 01:10:19
合計ジャッジ時間 1,983 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 25 WA * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         scanf("%lld%lld", &n, &l);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

typedef long long int LL;

LL n, l, ans;

int comp[1000001];

int main() {
	scanf("%lld%lld", &n, &l);
	
	for(int i = 2; i <= 1000000; i++) {
		if(comp[i] == 0) {
			for(int j = i * 2; j <= 1000000; j += i) {
				comp[j] = 1;
			}
		}
	}
	
	ans = 0;
	for(LL i = 2; i <= 1000000; i++) {
		if(comp[i] == 0) {
			LL temp = l + 1 - i * (n - 1);
			if(temp > 0) { ans += temp; }
		}
	}
	
	printf("%lld\n", ans);
	
	return 0;
}
0