結果

問題 No.3388 Sum of Function
コンテスト
ユーザー pengin_2000
提出日時 2025-11-28 21:26:12
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 426 bytes
コンパイル時間 186 ms
コンパイル使用メモリ 26,964 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-11-28 21:26:15
合計ジャッジ時間 1,181 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:19:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |         scanf("%lld %lld", &a, &b);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#include<stdio.h>
long long int f(long long int x)
{
	return x * x * x - x * x + x + 1;
}
long long int is_prime(long long int n)
{
	if (n < 2)
		return -1;
	long long int i;
	for (i = 2; i * i <= n; i++)
		if (n % i == 0)
			return -1;
	return 1;
}
int main()
{
	long long int a, b, i, ans = 0;
	scanf("%lld %lld", &a, &b);
	for (i = a; i <= b; i++)
		if (is_prime(i) > 0)
			ans += f(i);
	printf("%lld\n", ans);
	return 0;
}
0