NPOJ 1067 Flappy48

来源:互联网 发布:php strrops 编辑:程序博客网 时间:2024/06/18 04:44

题目大意:中文

注释代码:

/*                                                     * Problem ID : NPOJ 1067 Flappy48 * Author     : Lirx.t.Una                                                     * Language   : C++                                  * Run Time   : 1                                                     * Run Memory : 1692                                                  */ #include <iostream>#include <cstdio>#include <map>//最大的方块可能为2^40#defineMAXN41using namespace std;typedeflong longllg;map<llg, llg>score;//score[x]表示方块为x的分数intmain() {intt;//测例数intiscn;inti;//计数变量intn;//每个测例中有几个方块llgx;//方块上的数字llgans;//先对方块2 ~ 2^40的分数进行打表//score[x] = 2score[x/2] + xscore[2LL] = 0;for ( x = 4LL, i = 2; i < MAXN; i++, x <<= 1LL )score[x] = ( score[x >> 1LL] << 1LL ) + x;scanf("%d", &t);iscn = 0;while ( t-- ) {ans = 0;scanf("%d", &n);while ( n-- ) {scanf("%lld", &x);ans += score[x];}printf("Case %d: %lld\n", ++iscn, ans);}return 0;}

无注释代码:

#include <iostream>#include <cstdio>#include <map>#defineMAXN41using namespace std;typedeflong longllg;map<llg, llg>score;intmain() {intt;intiscn;inti;intn;llgx;llgans;score[2LL] = 0;for ( x = 4LL, i = 2; i < MAXN; i++, x <<= 1LL )score[x] = ( score[x >> 1LL] << 1LL ) + x;scanf("%d", &t);iscn = 0;while ( t-- ) {ans = 0;scanf("%d", &n);while ( n-- ) {scanf("%lld", &x);ans += score[x];}printf("Case %d: %lld\n", ++iscn, ans);}return 0;}

0 0
原创粉丝点击