結果
| 問題 |
No.262 面白くないビットすごろく
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-14 14:48:02 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,171 bytes |
| コンパイル時間 | 1,726 ms |
| コンパイル使用メモリ | 196,416 KB |
| 実行使用メモリ | 7,800 KB |
| 最終ジャッジ日時 | 2025-10-14 14:48:05 |
| 合計ジャッジ時間 | 2,583 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 WA * 2 |
コンパイルメッセージ
main.cpp: In function ‘Node F(int, int, int)’:
main.cpp:17:44: warning: narrowing conversion of ‘(((ll)((p + __builtin_popcount(((unsigned int)p))) + v)) - pw[t])’ from ‘ll’ {aka ‘long long int’} to ‘int’ [-Wnarrowing]
17 | return {1,p+__builtin_popcount(p)+v-pw[t]};
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
main.cpp: In function ‘int main()’:
main.cpp:32:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
32 | scanf("%lld",&n);
| ~~~~~^~~~~~~~~~~
ソースコード
/*
你能不能进省队?
初志贯彻!
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int T,now,cnt;
ll n,pw[63],ans;
struct Node{
ll c;
int t;
}f[63][63][63],res;
bool vis[63][63][63];
inline Node F(int p,int v,int t){
if(p+__builtin_popcount(p)+v>=pw[t])
return {1,p+__builtin_popcount(p)+v-pw[t]};
if(vis[p][v][t])
return f[p][v][t];
vis[p][v][t]=1;
f[p][v][t]=F(p,v,t-1);
res=F(f[p][v][t].t,v+1,t-1);
return f[p][v][t]={f[p][v][t].c+res.c,res.t};
}
int main(){
// scanf("%d",&T);
pw[0]=1;
for(int i=1;i<63;i++)
pw[i]=pw[i-1]<<1;
T=1;
while(T--){
scanf("%lld",&n);
now=1;ans=cnt=0;
for(int i=62;~i;i--)
if(n&pw[i]){
if(now>=pw[i])
now-=pw[i];
else{
res=F(now,cnt,i);
// printf("%d %d %d\n",i,res.c,res.t);
ans+=res.c;
now=res.t;
}
cnt++;
}
if(now)
puts("-1");
else
printf("%lld\n",ans);
}
return 0;
}