Submission #71422


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include<bits/stdc++.h>
#define dou double
#define ll long long
#define all(x) x.begin(),x.end()
#define gre greater<>()
#define int2 int,int
#define pb push_back
#define mp make_pair
#define emp emplace
#define rep(i,a,n) for(int i=(int)(a);i<(int)(n);i++)
#define p_rep(i,a,n) for(int i=(int)(a);i<=(int)(n);i++)
#define r_rep(i,a,n) for(int i=(int)(a);i>(int)(n);i--)
#define rp_rep(i,a,n) for(int i=(int)(a);i>=(int)(n);i--)
#define fir first
#define sec second
#define uns unsigned
#define fix(x,k) fixed<<setprecision(k)<<x
#define total(n) n*(n+1)/2 //nまでの総和
#define lcm(a,b) (a*b)/__gcd(a,b) //aとbの最小公倍数
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define vi vector<int>
#define vs vector<string>
#define uni(x) x.erase(unique(x.begin(),x.end()), x.end()) //vector重複削除
#define outSM(x) for(auto i=x.begin();i<x.end();i++) //set,map出力用ループ
#define INF 1e9
#define mod 1000000007
using namespace std;
int main(){
int n; cin>>n;
int sum=0;
while(n>1){
sum+=n%2;
n/=2;
}
cout<<sum+n<<"\n";
return 0;
}

ステータス

項目 データ
問題 1123 - こんなの一瞬だろ
ユーザー名 ei2113
投稿日時 2022-07-22 13:16:09
言語 C++17
状態 Accepted
得点 1
ソースコード長 1196 Byte
最大実行時間 34 ms
最大メモリ使用量 672 KB

セット

セット 得点 Cases
1 ALL 1 / 1 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
input-sample1 AC 29 ms 476 KB
1
input-sample2 AC 24 ms 452 KB
1
input01 AC 23 ms 672 KB
1
input02 AC 25 ms 512 KB
1
input03 AC 19 ms 484 KB
1
input04 AC 20 ms 460 KB
1
input05 AC 21 ms 560 KB
1
input06 AC 22 ms 536 KB
1
input07 AC 26 ms 504 KB
1
input08 AC 26 ms 476 KB
1
input09 AC 15 ms 448 KB
1
input10 AC 25 ms 548 KB
1
input11 AC 23 ms 520 KB
1
input12 AC 28 ms 496 KB
1
input13 AC 34 ms 468 KB
1
input14 AC 15 ms 572 KB
1
input15 AC 25 ms 544 KB
1