結果

問題 No.354 メルセンヌ素数
ユーザー Yatsuku
提出日時 2016-05-29 21:00:07
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 276 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 22,656 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-07 17:45:42
合計ジャッジ時間 872 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other WA * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:7:9: warning: ignoring return value of ‘fscanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         fscanf(stderr, "%lu", &num);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <math.h>

int main(void)
{
	unsigned long num;	
	fscanf(stderr, "%lu", &num);

	unsigned long cnt = 0;
	num = (long)pow(2, num) - 1;
	while ( num != 0 ) {
		if ( num & 1 ) { cnt++; }
		num >>= 1;  
	}

	fprintf(stderr, "%lu\n", cnt);
	return 0;
}

0