- 博客(83)
- 收藏
- 关注
原创 POJ 1703 种类并查集
题意:一个城市里面有两个黑帮 有两种操作 A(ask) 询问 x,y的关系 D x,y是一伙的很明显是种类并查集 于是就YY一下 relationsi 表示与父节点的关系 fatheri 记录父节点 在合并和查询root的时候 relations 更新注意一下就可以了#include #include using namespace std;const int maxn = 100
2015-08-10 15:41:51
508
原创 HDU 2852 线段树(查询有序位置)
题意:有三种操作 操作0 增添数字 操作1 删除数字 操作2 a k 查询大于a的第k个数 这道题与 HDU 4006 POJ 2828 类似基本上都是找有序位置详细的解释 传送门这道题的不同 tree.sum 记录的还是当前结点所含有的数字个数操作0这里就不多说了 操作1 如何判断是否存在 即判断[1,x] and [1,x-1]这两个区间的sum值是否不同操
2015-08-08 19:42:17
470
原创 HDU 4006 POJ 2828 线段树(排列/找有序位置)
又是一年一度的暑假集训 然而前几天刚做完搜索 还木有做明白 现在就跑过来做线段树 唉 不知道我这个弱弱什么时候才能变得不那么弱~HDU 4006 与 POJ 2828 两题相类似HDU 4006 是找第K大的数 POJ 2828是把数字插入到指定位置然后输出arry 两题都属于线段树单点更新的问题 HDU 4006 tree[root].sum 记录该节点一共有多少个数字 若目前出
2015-08-08 16:31:04
734
原创 FZU 1752 Quickmod Quickmulti
题意 :Given A,B,C, You should quickly calculate the result of A^B mod C. (1原始的Quickmod 和 QuickmultiLL QuickMod(LL a,LL b,LL c){ LL ans = 1; while(b) { if(b&1) ans = ans*a%c;
2015-08-03 22:27:49
495
原创 HDU 1452 Happy 2004
2004 = 2^2*3*1672004^x = 2^2*x*3^x*167^xsum(x) 表示 x 的因子和则有 sum(2004^x) %29 = (2^2*x)%29*(3^x)%29*(167^x)%29∵ 167 % 29 = 22∴ sum(2004^x)%29 = (2^2*x)%29*(3^x)%29*(22^x)%29
2015-08-02 20:14:30
361
转载 UVA 题目难度 分级
#IDTitleSolved byDifficulty1100The 3n + 1 problem2648512102Ecological Bin Packing106082310071Back to High School Physics95543410055Hashmat t
2015-08-02 19:52:26
26548
原创 CF 439D Devu and his Brother
可贪心 可三分三分要比贪心运行时间短一些贪心要保证 b_arry 的逆序排列对应的 a_arry 的正序排列的每个数都要小#include #include #include using namespace std;const int maxn = 1e5 + 100;int a[maxn];int b[maxn];int n,m;int main()
2015-08-02 16:32:52
455
原创 CF 474B Worms
二分查找#include #include using namespace std;const int maxn = 1e5 + 100;int len[maxn];int up[maxn];int n,m;int bin_search(int x){ int l = 1,r = n; if(x >= up[r]) return
2015-08-02 13:56:59
453
原创 ZOJ 3203 三分
#include #include using namespace std;const double eps = 1e-9;double H,h,D;double f(double x){ return D-x+H-(H-h)*D/x;}double solve(double left,double right){ double mid,midmid,d1,d2
2015-08-01 17:43:52
325
原创 HDU 4355 三分
#include #include #include #include using namespace std;const int maxn = 50100;const double eps = 1e-5;int n;double data[maxn][2];double cal(double x){ double ans = 0; for(int i = 0
2015-08-01 17:43:10
441
原创 Codeforces Round #313 (Div. 2) D Equivalent Strings
题意 划分字符串 a1 b1 a2 b2 若a1=b2&&a2=b1 || a1=b1&&a2=b2 输出YES若为偶数则不断划分 到奇数的时候则判断 两个字符串每一位是否相等 不能用strcmp#include #include #include #include using namespace std;const int MAX = 200100;char str1[M
2015-07-25 22:05:45
409
原创 Codeforces Round #313 (Div. 2) A B C
这三题 都挺水的 考读题。。A题意 给定n种面值的钱 输出所不能表示的最小价值 若都能表示则输出-1#include #include #include using namespace std;int main(){ int n; int ary[1010]; while(cin>>n) { for(int i = 0;i <
2015-07-25 20:35:20
414
原创 CF 558C Amr and Chemistry
#include #include #include #include using namespace std;const int MAX = 100100;int n,data;int gt[MAX],sum[MAX];/** 分析 两个数组 gt[t]把ary中的数转化为t所需要的最小操作数 sum[t] 能到达t的数个数 要注意 奇数/2*2的情况**/
2015-07-23 16:01:04
423
原创 CF 558B Amr and The Large Array
#include #include #include #include #define INF 2139062143using namespace std;const int MAX = 1001000;int n;int l[MAX],r[MAX],sum[MAX];int main(){ while(cin>>n) { memset(sum,
2015-07-22 22:52:49
403
原创 CF 558A Lala Land and Apple Trees
军训 好久没有A题了这阵时间心好烦 有好多事情困扰我 唉~#include #include #include using namespace std;struct tree{ int pos,sum;}data_z[110],data_f[110];int cmp_z(const tree&a,const tree&b){ return a.pos <
2015-07-22 19:53:50
518
原创 临时占坑 大一实习 学生信息管理系统
#include #include #include #include #include using namespace std;struct STU{ int id; char name[20]; char sex; double score[5]; double ave,sum; int _rank;}data[100];int
2015-07-13 23:01:32
479
原创 CF 18B Platforms
模拟题细节处理好就可以啦 >_#include #include using namespace std;typedef long long LL;const int MAX = 1e6 + 100;struct ax{ LL left,right;}data[MAX];int n,d,m,l;int main(){ // (k-1)m,(k-1)m +
2015-07-11 23:20:57
426
原创 CF 17A Noldbach problem
题意 给定n k 求小于等于n 的数能拆成两个相邻的素数和1的和 这样的数的个数是否大于等于k#include #include #include using namespace std;bool isprime[1010];int prime[1010],sum_prime;void get_prime(){ sum_prime = 0; memset(isp
2015-07-11 20:16:08
554
原创 CF 7C Line
裸拓展欧几里得#include #include #include #include using namespace std;typedef long long LL;LL gcd(LL a,LL b){ return b ? gcd(b,a%b):a;}void ex_gcd(LL a,LL b,LL &x,LL &y){ if(b == 0)
2015-07-10 19:15:58
561
原创 CF 3C Tic-tac-toe
此题只要考虑全面就可以额愁死了#include #include #include using namespace std;char data[5][5];int _win[2][10];// 行123 列123 \/int judgement(char c){ int judge = 0; for(int i = 0; i < 3; i ++) {
2015-07-09 16:07:21
590
原创 CF 3B Lorry
sort + greedy 为了满足各种判断条件 这样做应该是比较优的全都用1的 全都用2的 1 2混合使用的#include #include #include using namespace std;typedef long long LL;const int MAX = 1e5 + 1000;struct bb{ int t,p,num;} kay[MA
2015-07-09 11:18:21
556
原创 CF 554B Ohana Cleans Up
想清楚 看有多少一样的行#include #include #include using namespace std;char data[110][110];int num_same[110];/** 0101 1000 1111 0101*/int main(){ int n; while(cin>>n) {
2015-07-07 10:13:12
453
原创 CF 29A Spit Problem
水题#include using namespace std;int main(){ int n; int data[110][2]; while(cin>>n) { for(int i = 0;i < n;i ++) cin>>data[i][0]>>data[i][1]; int flag
2015-06-27 11:22:08
500
原创 CF 12C Fruits
仔细做一下就好了有许多细节处理(也许我做麻烦了)#include #include #include #include #include using namespace std;struct fr{ char name[110]; int sum; int pp;}data[110];int cmp1(const fr&a,const fr&b)
2015-06-25 22:14:53
523
原创 CF 12B Correct Solution?
题意 给两个数 问第一个数重新排列后最小的非前导零的数是否是第二个#include #include #include #include using namespace std;int main(){ char a[15],b[15]; while(cin>>a>>b) { int len_a = strlen(a); so
2015-06-25 19:18:51
516
原创 CF 14A Letter
题意 貌似是给定二维字符串组 输出以最外层的*为框框的二维字符串组找到上下左右的边界即可#include #include #include using namespace std;int main(){ int n,m; char data[50][50]; while(cin>>n>>m) { getchar();
2015-06-24 23:49:49
527
原创 CF 11B Jumping Jack
首先处理正负最优解即是 一直向右跳 正好等于x 若不能正好等于x 则要找大于x 的第一个距离 y 若(y-x)是偶数的话 则第(y-x)/2步向左跳 若为奇数 则继续向下找偶数#include #include using namespace std;int main(){ int x; while(cin>>x) { if(x <
2015-06-24 23:07:39
711
原创 CF 10A Power Consumption Calculation
shui#include using namespace std;int main(){ int n,p1,p2,p3,t1,t2; int data_time[110][2]; while(cin>>n>>p1>>p2>>p3>>t1>>t2) { for(int i = 1;i <= n;i ++) cin>
2015-06-24 16:39:19
464
原创 CF 9C Hexadecimal's Numbers
组合数的题 一开始本来想纯暴力 结果超时了后来想一共最多9位数 可以将1~2^9用十进制存到数组中 然后找到n的上界就ok了#include using namespace std;int bin[550];int main(){ for(int i = 1;i <= 512;i ++) { int tmp = 0; for(
2015-06-23 23:43:04
524
原创 CF 552B Vanya and Books
shui shui 没有找到比较好的方法#include #include #include using namespace std;int main(){ char num_c[20]; while(cin>>num_c) { long long ans = 0; int num_len = strlen(num_c);
2015-06-23 15:43:33
707
原创 CF 9B Running Student
#include #include using namespace std;int main(){ int n,data[105],vb,vs,x,y,ans; while(cin>>n>>vb>>vs) { ans = 0; for(int i = 1;i <= n;++ i) cin>>data[i];
2015-06-22 12:11:05
432
原创 CF 9A Die Roll
水的要死 像我一开始玩rv 一样 #include #include using namespace std;int main(){ int a,b; while(cin>>a>>b) { if(a<b) swap(a,b); if(a == 1) cout<<"1/1"<<endl; if(a == 2) c
2015-06-21 23:21:19
480
原创 CF 8A Train and Peter
前些日子看了一看 string 的用法 没想到水到了这题 find函数如果找不到 返回值为 -1 ?题意 正向反向顺序查找字串 如果只有正向能找到 输出 forward 如果反向能找到 输出 backwards 如果双向都能找到 输出both 找不到 输出 fantasy#include #include using namespace std;int main(){
2015-06-18 23:18:35
564
原创 CF 7A Kalevitch and Chess
水~#include #include using namespace std;char data[10][10];int main(){ while(cin>>data[0]) { for(int i = 1;i <8;i ++) cin>>data[i]; int ans = 0,h = 0,l = 0,
2015-06-17 22:30:26
434
原创 CF 6C Alice, Bob and Chocolate
还是跪了n发开始比大小跑数组后来想起了以前的做法 记两个和跑#include #include using namespace std;const int MAX = 100100;int n;int data[MAX];int main(){ int n; while(cin>>n) { for(int i = 0; i <
2015-06-17 22:20:26
495
原创 CF 6B President's Office
继续水~先水完 D2 ABC 再说#include #include using namespace std;int n,m;int sum[30],tx[4]={0,0,1,-1},ty[4]={1,-1,0,0};char pd;char data[105][105];void solve(int i,int j){ if(i=n||j=m)
2015-06-17 16:16:43
445
原创 CF 5B Center Alignment
水的要死 没看懂题目 错了N发#include #include #include #include #include using namespace std;const int MAX = 1005;char data[MAX][MAX];int data_len[MAX];int main(){ int num = 0,max_len = 0; whi
2015-06-17 14:13:25
491
原创 CF 1B Spreadsheet
简直弱爆了 各种错#include #include #include #include using namespace std;int n;char data[1000];int change[1000];char ans [1000];int main(){ while(~scanf("%d",&n)) { while(n--)
2015-06-16 13:00:24
445
原创 CF 546B Soldier and Badges
其实还是挺水的注意两个问题 最终结果要定义longlongbool 数组要开的大一些#include #include #include using namespace std;bool pos[100000];long long data[3100];int main(){ int n; while(~scanf("%d",&n)) {
2015-06-10 21:22:55
431
原创 HDU 1698 区间更新 求和
#include #include using namespace std;const int MAX = 100100;struct Tree{ int l,r,mark;}tree[MAX * 4];void BuildTree(int root,int l,int r){ tree[root].l = l; tree[root].r = r;
2015-06-07 17:39:19
391
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人