結果
問題 | No.642 Two Operations No.1 |
ユーザー |
![]() |
提出日時 | 2018-02-02 23:07:04 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 691 bytes |
コンパイル時間 | 1,413 ms |
コンパイル使用メモリ | 159,440 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-31 08:06:51 |
合計ジャッジ時間 | 1,926 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0;i<n;i++) #define REPR(i,n) for(int i=n;i>=0;i--) #define EPS (1e-7) typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<double,double> pdd; int vx[]={0,0,-1,1}; int vy[]={1,-1,0,0}; int dx[]={1,0,-1,1,-1,1,0,-1}; int dy[]={1,1,1,0,0,-1,-1,-1}; const ll mod=1e9+7; const int INF=INT_MAX/2; const int MAX=1e9; int dp[10000]; int main(){ int n; cin>>n; int k=1; int cnt=0; while(k<n){ k*=2; cnt++; } int res=k-n; while(res>0){ int s=1; int times=0; while(s<=res){ s*=2; times++; } s/=2; times--; res-=s; cnt++; } cout<<cnt<<endl; return 0; }