HDU 2035 不忍直视的水】的更多相关文章

#include <iostream> #include <cstdio> #include <algorithm> using namespace std; int main(){ int a,b; while(scanf("%d%d",&a,&b)!=EOF){ if(!a&&!b) break; int ans=1; for(int i=1;i<=b;i++) ans=(ans*a)%1000; print…
同余问题 基本定理: 若a,b,c,d是整数,m是正整数, a = b(mod m), c = d(mod m) a+c = b+c(mod m) ac = bc(mod m) ax+cy = bx+dy(mod m) -同余式可以相加 ac = bd(mod m) -同余式可以相乘 a^n = b^n(mod m) f(a) = f(b)(mod m) if a = b(mod m) and d|m then a = b(mod d) eg: 320 = 20(mod 100) and d =…
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2035 人见人爱A^B Description 求A^B的最后三位数表示的整数.说明:A^B的含义是“A的B次方” Input 输入数据包含多个测试实例,每个实例占一行,由两个正整数A和B组成(1<=A,B<=10000),如果A=0, B=0,则表示输入数据的结束,不做处理. Output 对于每个测试实例,请输出A^B的最后三位表示的整数,每个输出占一行. Sample Input 2 312…
http://acm.hdu.edu.cn/showproblem.php?pid=4940 给出一个有向强连通图,每条边有两个值分别是破坏该边的代价和把该边建成无向边的代价(建立无向边的前提是删除该边)问是否存在一个集合S,和一个集合的补集T,破坏所有S集合到T集合的边代价和是X,然后修复T到S的边为无向边代价和是Y,满足Y<x:满足输出unhappy,否则输出happy: 思路是让T集合的数目最少, 假如两个T集合里各有一个点且都满足Y>=X,那这两个点合并成一个T集合的话,只会使Y不会比…
排序 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 30009    Accepted Submission(s): 8326 Problem Description 输入一行数字,如果我们把这行数字中的‘5’都看成空格,那么就得到一行用空格分割的若干非负整数(可能有些整数以‘0’开头,这些头部的‘0’应该被忽略掉,除非这个整数就是由若…
Monster 题目链接: http://acm.hust.edu.cn/vjudge/contest/123554#problem/I Description Teacher Mai has a kingdom. A monster has invaded this kingdom, and Teacher Mai wants to kill it. Monster initially has h HP. And it will die if HP is less than 1. Teache…
Hard Code Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=95149#problem/A Description Some strange code is sent to Da Shan High School. It's said to be the prophet's note. The note is extremely hard t…
H - RobotTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87326#problem/H Description A robot is a mechanical or virtual artificial agent, usually an electro-mechanical machine that is guided by a com…
Problem Description We divide the HZNU Campus into N*M grids. As you can see from the picture below, the green grids represent the buidings. Given the size of the HZNU Campus, and the color of each grid, you should count how many green grids in the N…
Problem Description 给定一系列2维平面点的坐标(x, y),其中x和y均为整数,要求用一个最小的长方形框将所有点框在内.长方形框的边分别平行于x和y坐标轴,点落在边上也算是被框在内. Input 测试输入包含若干测试用例,每个测试用例由一系列坐标组成,每对坐标占一行,其中|x|和|y|小于 231:一对0 坐标标志着一个测试用例的结束.注意(0, 0)不作为任何一个测试用例里面的点.一个没有点的测试用例标志着整个输入的结束. Output 对每个测试用例,在1行内输出2对整数…
Permutation Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequences h1∼hn and c1∼cn. h1∼hn is a permutation of 1∼n. particularly, h0=hn+1=0. We define the expression [condition] is 1 when condition is True,is 0 whe…
Sqrt Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5752 Description Let's define the function f(n)=⌊n−−√⌋. Bo wanted to know the minimum number y which satisfies fy(n)=1. note:f1(n)=f(n),fy(n)=f(fy−1(n)) It is a pity that Bo can only use 1 unit…
n*n棋盘,初始左上角有一个石头,每次放只能在相邻的四个位置之一,不能操作者输. 如果以初始石头编号为1作为后手,那么对于每次先手胜的情况其最后一步的四周的编号必定是奇数,且此时编号为偶数,而对于一个局面,每个人都可以操控方向以致走完整个棋盘,所以当棋盘总格数为偶数时,先手必胜,而为奇数时,后手必胜. /** @Date : 2017-10-13 21:22:47 * @FileName: HDU 1564 简单博弈.cpp * @Platform: Windows * @Author : Lw…
排列2 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 9583    Accepted Submission(s): 3485 Problem Description Ray又对数字的列产生了兴趣: 现有四张卡片,用这四张卡片能排列出很多不同的4位数,要求按从小到大的顺序输出这些4位数.   Input 每组数据占一行,代表四张卡片上…
Pet Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 181    Accepted Submission(s): 55 Problem Description One day, Lin Ji wake up in the morning and found that his pethamster escaped. He searche…
Shaking hands Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5232 Description Today is Gorwin’s birthday, so she holds a party and invites her friends to participate. She will invite n friends, for convenience…
Tutor Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 47    Accepted Submission(s): 26 Problem Description Lilin was a student of Tonghua Normal University. She is studying at University of Chic…
Text Reverse Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 24157    Accepted Submission(s): 9311 Problem Description Ignatius likes to write words in reverse way. Given a single line of text…
The Water Problem Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1308    Accepted Submission(s): 1038 Problem Description In Land waterless, water is a very limited resource. People always fi…
http://acm.hdu.edu.cn/showproblem.php?pid=5007 #include<iostream> #include<stdio.h> #include<string.h> #include<string> #include<stack> #include<queue> #include<map> #include<set> #include<vector> #inc…
there are N ACMers in HDU team.ZJPCPC Sunny Cup 2007 is coming, and lcy want to select some excellent ACMers to attend the contest. There have been M matches since the last few days(No two ACMers will meet each other at two matches, means between two…
作为杭电的老师,最盼望的日子就是每月的8号了,因为这一天是发工资的日子,养家糊口就靠它了,呵呵  但是对于学校财务处的工作人员来说,这一天则是很忙碌的一天,财务处的小胡老师最近就在考虑一个问题:如果每个老师的工资额都知道,最少需要准备多少张人民币,才能在给每位老师发工资的时候都不用老师找零呢?  这里假设老师的工资都是正整数,单位元,人民币一共有100元.50元.10元.5元.2元和1元六种. Input 输入数据包含多个测试实例,每个测试实例的第一行是一个整数n(n<100),表示老师的人数,…
题意: M*N的grid,每个格上有一个整数. 小明从左上角(1,1)打算走到右下角(M,N). 每次可以向下走一格,或向右走一格,或向右走到当前所在列的倍数的列的位置上.即:若当前位置是(i,j),可以走到(i,k*j) 问取走的最大和是多少. 思路: 水DP...边界的初始化要考虑.(因为有负数). 代码: int n,m; int a[30][1005]; int dp[30][1005]; int main(){ int T; cin>>T; while(T--){ cin>&g…
题目描述: 输入一行数字,如果我们把这行数字中的'5'都看成空格,那么就得到一行用空格分割的若干非负整数(可能有些整数以'0'开头,这些头部的'0'应该被忽略掉,除非这个整数就是由若干个'0'组成的,这时这个整数就是0).你的任务是:对这些分割得到的整数,依从小到大的顺序排序输出. 输入: 输入包含多组测试用例,每组输入数据只有一行数字(数字之间没有空格),这行数字的长度不大于1000.输入数据保证:分割得到的非负整数不会大于100000000:输入数据不可能全由'5'组成. 例如:005123…
解题思路: 1. 遍历扫描二维数组,遇到‘@’,结果ans++; 2. 将当前 i,j 位置置为‘*’,将当前‘@’的 i,j 传人到DFS函数中,开始遍历八个方向的字符 如果碰到 '@' 则先将当前置为‘*’,然后再次递归传递,直到超出界限或者扫描不到‘@’,结束递归 3. DFS()的作用是将i,j为开始周围连续的“@”全部改为‘*’ 4. 最后输出 ans 即可: Ac code : #include<bits/stdc++.h> using namespace std; ][]; st…
很裸的一道最大流 格式懒得排了,注意把人拆成两份,一份连接食物,一份连接饮料 4 3 3 //4个人,3种食物,3种饮料 1 1 1 //食物每种分别为1 1 1 1 //饮料每种数目分别为1 YYN //第一个人对第1,2,3种食物的态度为接受,接受和拒绝 NYY YNY YNY YNY //第一个人对第1,2,3种饮料的态度为接受,拒绝和接受 YYN YYN NNY 3 #include<cstdio> #include<iostream> #include<algori…
Switch Game Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10200    Accepted Submission(s): 6175 Problem Description There are many lamps in a line. All of them are off at first. A series of op…
#include<bits/stdc++.h> using namespace std; #define ll long long #define pi (4*atan(1.0)) #define eps 1e-14 ,M=4e6+,inf=1e9+,mod=1e9+; ; struct is { int x; int pos; }a[N]; int cmp1(is a,is b) { if(a.x!=b.x) return a.x<b.x; return a.pos<b.pos;…
Ps:查了下快速幂,顺便在这用下.... 积的求余等于两个数的求余的积再求余... 代码: #include "stdio.h"int mod(int a,int b);int main(){ int a,b,n; while(~scanf("%d%d",&a,&b) &&(a||b) ){  printf("%d\n",mod(a,b));  } return 0;}int mod(int a,int b){ i…
题意:beautiful数字定义为该数字中的十进制形式每一位都不同,给一个区间[L,R],求该区间中有多少个beautiful数字. 思路:数字不大,直接暴力预处理,再统计区间[1,i]有多少个,用cnt[R]-cnt[L-1]即可. #include <bits/stdc++.h> #define INF 0x7f7f7f7f #define pii pair<int,int> #define LL long long using namespace std; ; ]; int…