結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
springroll
|
| 提出日時 | 2018-10-29 03:09:14 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 529 bytes |
| コンパイル時間 | 1,716 ms |
| コンパイル使用メモリ | 166,312 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-19 07:28:15 |
| 合計ジャッジ時間 | 2,829 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 WA * 16 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
int main() {
int N;
cin >> N;
int i=1, n=14, ans=1;
while (1) {
int cnt=0;
//cout << bitset<10>(i) << endl;
for (int bit = 0; bit < n; bit++) {
if (i & (1 << bit)) {
cnt++;
}
}
//cout <<" "<< cnt <<" "<< i+cnt << endl;
if ((i + cnt) > N) {
i -= cnt;
}
else {
i += cnt;
}
//cout <<" "<< i << endl;
ans++;
//printf("%d\n",ans);
if(i==N) break;
if (ans > (int)1e3) {
cout << -1 << endl;
return 0;
}
}
cout << ans << endl;
}
springroll