結果
問題 | No.2880 Max Sigma Mod |
ユーザー |
|
提出日時 | 2024-09-18 00:05:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 477 bytes |
コンパイル時間 | 1,761 ms |
コンパイル使用メモリ | 166,416 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-18 00:06:01 |
合計ジャッジ時間 | 3,549 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 WA * 28 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:25:16: warning: 'nw' may be used uninitialized [-Wmaybe-uninitialized] 25 | ans+=nw%j; | ~~^~ main.cpp:13:9: note: 'nw' was declared here 13 | int nw,ans=0; | ^~
ソースコード
#include<bits/stdc++.h>using namespace std;#define int long longbool test(int x){for(int i=2;i*i<=x;i++){if(x%i==0) return false;}return true;}signed main() {int n,m;cin>>n>>m;int nw,ans=0;if(m>n){nw=n;}else{for(int i=n;i>1;i--){if(test(i)) {nw=i;break;}}}for(int j=1;j<=m;j++){ans+=nw%j;}cout<<ans<<'\n';}