Mar
17
SGU 126 解题手记
2007 解题报告 Popularity: 1%
哎……只差一个证明就够称为“解题报告”了……SGU 126 解题手记
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 | //AC #include <iostream> using namespace std; long gcd(long a,long b) { long t; while (b) { t=a; a=b; b=t%b; } return a; } long log2(long a) { int i=0; for (;a>1;++i,a>>=1); return i; } int main() { long a,b,t; cin>>a>>b; if (a>0 && b>0) { t=(a+b)/gcd(a,b); if ((t-1)&t) cout<<-1; else cout<<log2(t); } else cout<<0; cout<<endl; } |
- http://www.briefdream.com/sgu-126/
- Tags:MaShuo, SGU, 博弈, 解题报告
- (0)comments | leave a reply
- Trackback URI