結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー RIGIH
提出日時 2017-06-27 02:24:38
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 464 bytes
コンパイル時間 438 ms
コンパイル使用メモリ 58,200 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-04 10:04:10
合計ジャッジ時間 5,203 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4 WA * 1
other AC * 24 WA * 5 TLE * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:27:26: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
   27 |                 printf("%d\n",(a+1)*z-(n-1)*ds);
      |                         ~^    ~~~~~~~~~~~~~~~~
      |                          |           |
      |                          int         long long int
      |                         %lld

ソースコード

diff #


#include<stdio.h>
#include <iostream>
#include <cstring>
#include <math.h>
using namespace std;

int sosu(int);

int main(){
	//while(1){

		long long n,a;
		
		cin>>n>>a;
		int x=a/(n-1);
		long ds=0;
		int z=0;

		for(int d=2;d<=x;d++){
			if(sosu(d)){
				ds+=d;
				z++;
			}
		}
		printf("%d\n",(a+1)*z-(n-1)*ds);
		//cout<<(a+1)*z-(n-1)*ds<<endl;

		
	//}



	
	return 0;
}

int sosu(int n){
	int i;
	for(i=2;i*i<=n;i++) if(n%i==0) return 0;
	return 1;
}

0