ACdream原创群赛(18)のAK's dream
来源:互联网 发布:淘宝客服周总结 编辑:程序博客网 时间:2024/05/20 23:33
A -KIDx's Pagination
Problem Description
One Day, KIDx developed a beautiful pagination for ACdream. Now, KIDx wants you to make another one.
The are n pages in total.
The current page is cur.
The max distance to current page you can display is d.
Here are some rules:
- The cur page button is disabled.
- If cur page is the first page, the button "<<" should be disabled.
- If cur page is the last page, the button ">>" should be disabled.
- If the button "x" is disabled, print "[x]"; else print "(x)".
- You should not display the "..." button when there is no hidden page.
You can assume that the button "..." is always disabled.
Input
Ease case contains three integers n, cur, d.
1 ≤ n ≤ 100.
1 ≤ cur ≤ n.
0 ≤ d ≤ n.
Output
Sample Input
10 5 210 1 2
Sample Output
Case #1: (<<)[...](3)(4)[5](6)(7)[...](>>)Case #2: [<<][1](2)(3)[...](>>)
Hint
Case 1:
Case 2:
AC代码:
/** this code is made by eagle* Problem: 1196* Verdict: Accepted* Submission Date: 2014-09-06 20:08:40* Time: 0MS* Memory: 1676KB*/#include <iostream>#include <cstdio> using namespace std; int main(){ int n,cur,d,tp,cnt = 0; //freopen("in.txt","r",stdin); while(~scanf("%d %d %d",&n,&cur,&d)) { printf("Case #%d: ",++cnt); if(cur != 1) printf("(<<)"); else printf("[<<]"); if(cur - d > 1) printf("[...]"); if(cur - d < 1) tp = 1; else tp = cur - d; for(int i = tp; i < cur && i >= 1; i++) printf("(%d)",i); printf("[%d]",cur); for(int i = cur + 1; i <= cur + d && i <= n; i++) printf("(%d)",i); if(cur + d < n) printf("[...]"); if(cur != n) printf("(>>)"); else printf("[>>]"); puts(""); } return 0;}
D -Heros and Swords
Problem Description
There are n swords of different weights Wi and n heros of power Pi.
Your task is to find out how many ways the heros can carry the swords so that each hero carries exactly one sword.
Here are some rules:
(1) Every sword is carried by one hero and a hero cannot carry a sword whose weight is larger than his power.
(2) Two ways will be considered different if at least one hero carries a different sword.
Input
The first line of the input gives the number of test cases T(1 ≤ T ≤ 50).
Each case starts with a line containing an integer n (1 ≤ n ≤ 105)denoting the number of heros and swords.
The next line contains n space separated distinct integers denoting the weight of swords.
The next line contains n space separated distinct integers denoting the power for the heros.
The weights and the powers lie in the range [1, 109].
Output
For each case, output one line containing "Case #x: " followed by the number of ways those heros can carry the swords.
This number can be very big. So print the result modulo 1000 000 007.
Sample Input
351 2 3 4 51 2 3 4 521 32 232 3 46 3 5
Sample Output
Case #1: 1Case #2: 0Case #3: 4
/** this code is made by eagle* Problem: 1199* Verdict: Accepted* Submission Date: 2014-09-06 20:57:36* Time: 532MS* Memory: 2456KB*/#include <algorithm>#include <iostream>#include <cstdlib>#include <cstring>#include <cstdio> using namespace std;const int M = 1e5 + 5;const int mod = 1000000007;int a[M],b[M]; int main(){// freopen("in.txt","r",stdin); int T,n,cnt = 0; scanf("%d",&T); while(T--) { printf("Case #%d: ",++cnt); long long ans = 1; int vis = 0; scanf("%d",&n); for(int i = 0; i < n; i++) scanf("%d",a + i); for(int i = 0; i < n; i++) scanf("%d",b + i); sort(b, b + n); sort(a, a + n); for(int i = n - 1; i >= 0; i--) { int tp = lower_bound(b, b + n,a[i]) - b; if(tp == n) { vis = 1; break; } else { ans = ( ans * (i + 1 - tp) ) % mod; } } if(vis) puts("0"); else printf("%lld\n",ans); } return 0;}
G -Integer in C++
Problem Description
KIDx: I like Java much more than C++, because I can use BigInteger in Java. :)
However, KIDx has to use C++ language to do a project...
KIDx can only use three integer types in C++:
1) short occupies 2 bytes and allows you to store numbers from-32768 to 32767
2) int occupies 4 bytes and allows you to store numbers from -2147483648 to 2147483647
3) long long occupies 8 bytes and allows you to store numbers from-9223372036854775808 to 9223372036854775807
For all the types given above the boundary values are included in the value range.
From this list, KIDx wants you to choose the smallest type that can store a positive integern.
Input
There are multiple cases.
Each case contains a positive integer n.
It consists of at least one digit and at most 30 digits.
In addition, it doesn't contain any leading zeros.
Output
For each line, print the first type from the list "short, int, long long", that can store the natural numbern.
If no one can store the number, just print "It is too big!".
Sample Input
10250000
Sample Output
shortint
/** this code is made by eagle* Problem: 1202* Verdict: Accepted* Submission Date: 2014-09-06 20:36:06* Time: 0MS* Memory: 1676KB*/#include <iostream>#include <cstdlib>#include <cstring>#include <cstdio> using namespace std; int main(){ char s[33]; unsigned long long ans,tp; while(~scanf("%s",s)) { int len = strlen(s); if(len > 19) puts("It is too big!"); else { ans = 0; for(int i = 0; s[i]; i++) ans = ans * 10 + s[i] - '0'; if(ans > 9223372036854775807) puts("It is too big!"); else if(ans > 2147483647) puts("long long"); else if(ans > 32767) puts("int"); else puts("short"); } } return 0;}
I -Integration of Polynomial
Problem Description
Suppose there are a polynomial which has n nonzero terms, please print the integration polynomial of the given polynomial.
The polynomial will be given in the following way, and you should print the result in the same way:
k[1] e[1] k[2] e[2] ... k[n] e[n]
where k[i] and e[i] respectively represent the coefficients and exponents of nonzero terms, and satisfiese[1] < e[2] < ... < e[n].
Note:
- Suppose that the constant term of the integration polynomial is 0.
- If one coefficient of the integration polynomial is an integer, print it directly.
- If one coefficient of the integration polynomial is not an integer, please print it by using fractiona/b which satisfies thata is coprime to b.
Input
There are multiple cases.
For each case, the first line contains one integer n, representing the number of nonzero terms.
The second line contains 2*n integers, representing k[1], e[1], k[2], e[2], ..., k[n], e[n]。
1 ≤ n ≤ 1000
-1000 ≤ k[i] ≤ 1000, k[i] != 0, 1 ≤ i ≤ n
0 ≤ e[i] ≤ 1000, 1 ≤ i ≤ n
Output
Print the integration polynomial in one line with the same format as the input.
Notice that no extra space is allowed at the end of each line.
Sample Input
31 0 3 2 2 4
Sample Output
1 1 1 3 2/5 5
Hint
f(x) = 1 + 3x2 + 2x4
After integrating we get: ∫f(x)dx = x + x3 + (2/5)x5
AC代码:
/** this code is made by eagle* Problem: 1204* Verdict: Accepted* Submission Date: 2014-09-06 21:24:26* Time: 16MS* Memory: 1684KB*/#include <algorithm>#include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <cmath> using namespace std;const int M = 1100;const int mod = 1000000007;int a[M],b[M]; int gcd(int a, int b){ return b == 0 ? a : gcd(b, a % b);} int main(){ int n; while(~scanf("%d",&n)) { for(int i = 0; i < n; i++) { scanf("%d %d",a + i,b + i); b[i]++; } for(int i = 0; i < n; i++) { int tp = a[i] / b[i] * b[i]; if(tp == a[i]) printf("%d %d",a[i] / b[i],b[i]); else { tp = gcd(abs(a[i]),abs(b[i])); printf("%d/%d %d",a[i] / tp,b[i] / tp, b[i]); } if(i == n - 1) puts(""); else printf(" "); } } return 0;}
Xor
Problem Description
For given multisets
Note that for
Input
The first line contains a integer
The second line contains
The thrid line contains
(
Output
The only integer denotes the minimum
Sample Input
30 1 31 2 3
Sample Output
2
Source
Manager
数论,位进制和异或,首先要知道位为0的异或是不起作用的;
所以可以这样做,统计数的每一位的1的个数,如果不相等,则该位应该为1;
AC代码:
/** this code is made by eagle* Problem: 1023* Verdict: Accepted* Submission Date: 2014-09-07 20:08:14* Time: 624MS* Memory: 3240KB*/#include <algorithm>#include <iostream>#include <cstdio> using namespace std;typedef long long ll;const int M = 1e5 + 5;ll a[M],b[M];int ua[32],ub[32],n; void num(ll *a, int *c){ for(int i = 0; i < 30; i++) for(int j = 0; j < n; j++) c[i] += ( a[j] & (1 << i) ) ? 1 : 0;} int main(){ ll x,m; scanf("%d",&n); for(int i = 0; i < n; i++) cin>>a[i]; for(int i = 0; i < n; i++) cin>>b[i]; num(a,ua); num(b,ub); x = 0; m = 1; for(int i = 0; i < 30; i++) { if(ua[i] != ub[i]) x += m; m <<= 1; } for(int i = 0; i < n; i++) a[i] ^= x; sort(a, a + n); sort(b, b + n); for(int i = 0; i < n; i++) { if(a[i] != b[i]) { puts("-1"); return 0; } } cout<<x<<endl; return 0;}
- 【ACdream】ACdream原创群赛(18)のAK's dream
- ACdream原创群赛(18)のAK's dream
- ACdream原创群赛(18)のAK's dream
- ACdream原创群赛(18)のAK's dream
- 赛后打脸 - ACdream原创群赛(18)のAK's dream 简单题总结
- 【数位DP】ACdream原创群赛(15)の每题10s多开心 A - 喵喵的数字
- 拓扑排序 I - barty的智商 acdream ACdream原创群赛(12)のBUAA选拔赛
- 数论 D - 寒假安排 --acdream ACdream原创群赛(12)のBUAA选拔赛
- 数论 A - 梦 -----acdream ACdream原创群赛(12)のBUAA选拔赛
- [ACdream原创群赛の数树]解题报告
- ACdream原创群赛(12)のBUAA选拔赛
- ACdream原创群赛(13)のwuyiqi退役专场:LSS
- [ACdream原创群赛(12)のBUAA选拔赛]E:签到
- ACdream原创群赛(14)の我今天没吃药
- ACdream原创群赛(13)のwuyiqi退役专场
- ACdream原创群赛(14)の我今天没吃药
- ACdream原创群赛(12)のBUAA选拔赛 A - 梦
- ACdream原创群赛(13)のwuyiqi退役专场
- 写入内容到文件中
- 导入到Myeclipse中项目注释乱码问题
- iOS学习之UIActionSheet的使用
- hdu 1075 二分搜索
- 注册jdbc驱动程序的三种方式
- ACdream原创群赛(18)のAK's dream
- Apache MINA 快速入门以及架构介绍
- 使用dom4j四种读取xml文件的方法
- sqlite遇到database is locked问题的完美解决
- 注册、登陆、修改密码、添加、删除、查询的测试用例设计
- 最简单的Handler的用法
- FlashP2P系统(客户端)系统分析和设计谍照
- 矢量叉积与折线段拐向判断---三角形顺逆判断
- CentOS 7 安装无线网卡驱动