結果
| 問題 |
No.3 ビットすごろく
|
| コンテスト | |
| ユーザー |
chacoder1
|
| 提出日時 | 2021-06-27 17:06:10 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 749 bytes |
| コンパイル時間 | 1,884 ms |
| コンパイル使用メモリ | 194,756 KB |
| 最終ジャッジ日時 | 2025-01-22 14:41:40 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 WA * 15 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
int f(int x){
int ans=0;
while(x>0){
if(x%2==1) ans++;
x/=2;
}
return ans;
}
signed main(){
vector<int>cb(10100,-1);
int n;
cin>>n;
if(n==1){
cout<<1<<endl;
return 0;
}
int temp=1;
int cnt=1;
cb[temp]=1;
while(temp<=n){
if(temp+f(temp)>n){
cnt++;
temp-=f(temp);
if(cb[temp] != -1){
cout<<-1<<endl;
return 0;
}
else{
cb[temp]=cnt;
}
}
else{
cnt++;
temp+=f(temp);
cb[temp]=cnt;
}
if(temp==n){
cout<<cnt<<endl;
return 0;
}
}
cout<<-1<<endl;
return 0;
}
chacoder1