| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
怎么搞啊 啊啊In Reply To:本来玩得挺开心,被这道郁闷了, 那里不对了? Posted by:cuiaoxiang at 2006-11-18 13:41:31 > #include <iostream>
> #include <vector>
> using namespace std;
>
> vector<pair<int, int> > a;
>
> void run(__int64 n, int dep)
> {
> __int64 i;
> int j;
> for (i = 1, j = 0; i <= n; i += i, ++j);
> i /= 2, --j;
> if ((n - i) % 3) i /= 2, --j;
> a.push_back(make_pair(j, dep));
> n -= i;
> if (n == 0) return;
> j = 0;
> while (n % 3 == 0)
> {
> n /= 3;
> ++j;
> }
> run(n, dep + j);
> }
>
> int main()
> {
> int casenum, num, j;
> __int64 n;
> scanf("%d", &casenum);
> for (num = 1; num <= casenum; ++num)
> {
> a.clear();
> scanf("%I64d", &n);
> printf("%d", num);
> j = 0;
> while (n % 3 == 0)
> {
> n /= 3;
> ++j;
> }
> run(n, j);
> printf(" %d", a.size());
> for (vector<pair<int, int> >::iterator it = a.begin(); it != a.end(); ++it)
> printf(" [%d %d]", it->first, it->second);
> puts("");
> }
> return 0;
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator