結果
問題 |
No.638 Sum of "not power of 2"
|
ユーザー |
|
提出日時 | 2020-04-14 22:30:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 502 bytes |
コンパイル時間 | 2,326 ms |
コンパイル使用メモリ | 190,604 KB |
最終ジャッジ日時 | 2025-01-09 19:01:02 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:17:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 17 | lint n; scanf("%lld",&n); | ~~~~~^~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; using lint=long long; inline int popcount(long long x){ x-=(x>>1)&0x5555555555555555LL; x=(x&0x3333333333333333LL)+((x>>2)&0x3333333333333333LL); x=(x+(x>>4))&0x0f0f0f0f0f0f0f0fLL; x=(x*0x0101010101010101LL)>>56; return x; } int main(){ lint n; scanf("%lld",&n); lint a; for(a=1;a<n;a++) if(popcount(a)>1 && popcount(n-a)>1) break; if(a==n) puts("-1"); else printf("%lld %lld\n",a,n-a); return 0; }