結果
| 問題 | No.420 mod2漸化式 |
| コンテスト | |
| ユーザー |
okayunonaha
|
| 提出日時 | 2016-09-18 01:40:01 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 445 bytes |
| 記録 | |
| コンパイル時間 | 395 ms |
| コンパイル使用メモリ | 70,636 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-12 07:31:20 |
| 合計ジャッジ時間 | 1,715 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 1 |
| other | RE * 35 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:15:11: warning: iteration 2147483647 invokes undefined behavior [-Waggressive-loop-optimizations]
15 | dp[i] = dp[i/2] + (i % 2);
| ~~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:14:21: note: within this loop
14 | for (int i = 0; i <= m; i++) {
| ~~^~~~
ソースコード
#include <iostream>
using namespace std;
typedef long long ll;
#define int ll
int dp[2147483647];
signed main(void) {
int x, m = 2, Count, nsum, lastn;
Count = nsum = 0;
m <<= 30;
m--;
cin >> x;
for (int i = 0; i <= m; i++) {
dp[i] = dp[i/2] + (i % 2);
if(x == dp[i]) {
Count++;
nsum += i;
lastn = i;
}
}
//cout << "last = " << lastn << endl;
cout << Count << " " << nsum << endl;
return 0;
}
okayunonaha