hdoj:2035】的更多相关文章

#include <iostream> using namespace std; int main() { long a, b; && b != ) { long result = a; ; i <= b; i++) { result = (result * a) % ; } cout << result % << endl; } ; }…
Escape from Tetris Time Limit: 12000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1103    Accepted Submission(s): 280 Problem Description 由于整日整夜地对着这个棋盘,Lele终于走火入魔.每天一睡觉,他就会梦到自己会被人被扔进一个棋盘中,一直找不到出路,然后从梦中惊醒.久而久之…
基础题: 1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029.1032.1037.1040.1048.1056.1058.1061.1070.1076.1089.1090.1091.1092.1093.1094.1095.1096.1097.1098.1106.1108.1157.1163.1164.1170.1194.1196.1197.1201.1202.1205.1219.1234.1235.1236.1248.…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1533 解题心得: 第一次写最小费用流的题,去hdoj上找了一个入门级题目,建图比较简单,用了spfa和Dij两种写法. //spfa#include <bits/stdc++.h> using namespace std; *; struct edge{ int to, cap, dis, rev; edge(int To, int Cap, int Dis, int Rev): to(To),…
A1 = ? Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7535    Accepted Submission(s): 4675 Problem Description 有如下方程:Ai = (Ai-1 + Ai+1)/2 - Ci (i = 1, 2, 3, .... n).若给出A0, An+1, 和 C1, C2, .....…
核反应堆 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 15706    Accepted Submission(s): 7036 Problem Description 某核反应堆有两类事件发生:高能质点碰击核子时,质点被吸收,放出3个高能质点和1个低能质点:低能质点碰击核子时,质点被吸收,放出2个高能质点和1个低能质点.假定开始的时…
数塔 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 39043    Accepted Submission(s): 23246 Problem Description 在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的:有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少?已…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6333 解题心得: 这个题可以说是十分精彩了,首先推组合数学的公式,其中一个很重要的公式是Cnm = Cmn-1 + Cm-1n-1  这个公式知道杨辉三角的都明白,但是一看发现似乎没啥用.但是可以以这个公式为基础继续推演下去. 设Snm = Cn1 + Cn2 + Cn3 + ...... Cnm 然后继续使用上面的基本公式可以化成 Sn m-1 = Sn m - Cn m Sn m+1 = Sn…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6356 解题心得: 现在深深的知道了算法复杂度的重要了,这个题算复杂度的时候还要把一些常数也算出来,不然常数太大也容易凉凉阿.这个题的m的数量级比n的还要大一位,如果用离线对询问排序直接就TLE了. 其实这个题就是一个区间更新的线段树,只不过记录一下最小值,如果最小值大于将要更新的值就直接跳出,在线段树上剪枝.然而很迷的是在把m的内存开小了,开成n了居然不RE而是TLE,坑死了. // // ┏┛ ┻…
A|B? Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 18605    Accepted Submission(s): 14122 Problem Description 正整数A是否能被正整数B整除,不知道为什么xhd会研究这个问题,来帮帮他吧.   Input 输入数据的第一行是一个数据T,表示有T组数据.每组数据有两个正整数A和…
单词数 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 46381    Accepted Submission(s): 11369 Problem Description lily的好朋友xiaoou333最近很空,他想了一件没有什么意义的事情,就是统计一篇文章里不同单词的总数.下面你的任务是帮助xiaoou333解决这个问题.   I…
Max Num Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 22270    Accepted Submission(s): 13029 Problem Description There are some students in a class, Can you help teacher find the highest stude…
Fibbonacci Number Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 22530    Accepted Submission(s): 10375 Problem Description Your objective for this question is to develop a program which will g…
Coin Change Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 18271    Accepted Submission(s): 6291 Problem Description Suppose there are 5 types of coins: 50-cent, 25-cent, 10-cent, 5-cent, and 1…
根据公式计算卡特兰数,始终出现越界,自己无法解决 #include <iostream> using namespace std; long long Catalan(int num) { ; ; i <= num; i++) result *= (i + num); ; i <= num; i++) result /= i; result /= (num + ); return (long long)result; } int main() { int num; ; ) { pr…
#include <iostream> #include <string> using namespace std; int main() { int n,k; double gpa,s,credit,score; string name; bool flag = true; cin >> n; while (n--) { cin >> k; gpa = 0.0; s = 0.0; flag = true; ; i <= k; i++) { cin &…
  #include <iostream> #include <cmath> #include <vector> using namespace std; struct node{ int left; int right; }; int main() { long N, M; ; vector<node> nodes; while (cin >> N >> M) { && M == ) break; ; n--) {…
#include <cstdio> #include <cmath> #include <iostream> using namespace std; int main() { __int64 a, b; while(scanf("%I64X %I64X", &a, &b) != EOF) { printf(a+b < ? ? -a-b : a+b); } ; } 16进制的加法…
#include <iostream> #include <iomanip> #include <cstdlib> using namespace std; struct node { double a, b, c, d; node(){} void add(double a, double b, double c, double d){ this->a = a; this->b = b; this->c = c; this->d = d; }…
#include <iostream> #include <string> using namespace std; bool islower(char ch) { if (ch >= 'a' && ch <= 'z') return true; return false; } bool isUpper(char ch) { if (ch >= 'A' && ch <= 'Z') return true; return fal…
#include <iostream> #include <string> #include <vector> using namespace std; /* 无穷多次操作,第n灯的状态 */ int main() { long long n; while (cin >> n) { ; ; i <= n; i++) { ) { count++; } } == ) { cout << << endl; } else { cout…
#include <iostream> #include <string> using namespace std; int main() { int n, m; while (cin >> m >> n) { ; i <= n+; i++) { || i == n+) { cout << "+"; ; j <= m; j++) cout << "-"; cout <<…
#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; void toBit(int n) { vector<int> vec; ) { == ) { vec.push_back(); } else { vec.push_back(); } n /= ; } ; i >= ; i--) { cout &…
#include <iostream> using namespace std; int main() { int T; while (cin >> T) { ; i <= T; i++) { int n; cin >> n; cout << * n*n - n + << endl; } } } 太难,百度一下…
#include <iostream> using namespace std; ]; ]; int main() { int C; a[] = ; a[] = ; b[] = ; b[] = ; ; i <= ; i++) { a[i] = (i - )*(a[i - ] + a[i - ]); b[i] = i*b[i - ]; } while (cin >> C) { while (C--) { int n; cin >> n; printf("%…
#include <iostream> using namespace std; ] = { , , }; // O,E 组成长度为n的数量 long long fib(int n) { ) ; ) ; ; ; ) { long long f3 = f1 + f2; f1 = f2; f2 = f3; n--; } return f2; } int main() { int n; ]; b[] = ; b[] = ; ; i <= ; i++) { // 规律不对 // 2^n -2 是…
#include <iostream> using namespace std; long long fib(int n) { ) ; ) ; ; ; ) { long long f3 = f1 + f2; f1 = f2; f2 = f3; n--; } return f2; } int main() { int n; while (cin >> n) { cout << fib(n) << endl; } } http://acm.hdu.edu.cn/…
#include <iostream> using namespace std; ]; int main() { int n; a[] = ; a[] = ; a[] = ; ; i <= ; i++) { a[i] = a[i - ] + * a[i - ]; } while (cin >> n) { cout << a[n] << endl; } }…
#include <iostream> using namespace std; long long fib(int n) { ; ; ) ; ) { long long f2 = f0 + f1; f0 = f1; f1 = f2; n--; } return f1; } int main() { int n; while (cin >> n) { while (n--) { int a, b; cin >> a >> b; cout << f…
#include <iostream> #include <string> using namespace std; bool judgeSize(string str) { int size = str.size(); || size>) return false; return true; } int isA(string str) { for (auto &c : str) { if (c >= 'A' && c <= 'Z') ;…