- 博客(190)
- 资源 (2)
- 收藏
- 关注
原创 HDU 1408(盐水的故事)
基础题。#include <iostream>#include <cmath>using namespace std;int main(){ double VUL, D; while (cin >> VUL >> D) { int num = ceil(VUL / D); int...
2020-03-31 23:10:01 171
原创 HDU 1407(测试你是否和LTC水平一样高)
基础题。#include <iostream>using namespace std;int main(){ int num; int x, y, z; bool flag; while (cin >> num) { flag = true; for (x = 1; x <= 100...
2020-03-31 22:50:01 123
原创 HDU 1406(完数)
基础题。#include <iostream>#include <algorithm>using namespace std;//判断n是否为完数bool isPerfect(int n){ int sum = 0; for (int i = 1; i <= n / 2; i++) { if (n % i == 0) sum += i...
2020-03-31 22:33:45 129
原创 HDU 1405(The Last Practice)
基础题,注意输出格式,最后一个输出数字后面也有空格。#include <iostream>#include <cstring>#include <cmath>using namespace std;const int MAXN = 65536;int isPrime[MAXN];int main(){ memset(isPrime, 0...
2020-03-31 20:30:01 174
原创 HDU 1404(Digital Deletions)
可以确定 0 为必赢数,1 为必输数,所有能一步变成必输数的数为必赢数。从第一个必输数 1 开始,将所有能一步变成必输数的数记录为必赢数,详细见注释。#include <cstdio>#include <cstring>const int MAXN = 1000000;int win[MAXN]; //记录MAXN以内的每个数是必输数还是必赢数//计算...
2020-03-31 18:30:01 171
转载 HDU 1403(Longest Common Substring)
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int MAXN = 200005;char s[MAXN];int n;int sa[MAXN], t1[MAXN], t2[MAXN], c[MAXN], rnk[MAXN], h...
2020-03-31 17:00:01 94
转载 HDU 1402(A * B Problem Plus)
#include <iostream>#include <cstring>#include <algorithm>using namespace std;const int N = 50005;__int64 G = 3, P = 469762049, wn[25];char s1[N], s2[N];__int64 a[3 * N], b[3...
2020-03-30 22:22:22 142
转载 HDU 1401(Solitaire)
#include <iostream>#include <map>#include <queue>using namespace std;struct point //棋子{ int x; int y;};struct node //棋盘{ point p[4]; //四个棋子 int step; //移动步...
2020-03-30 17:20:00 189
转载 HDU 1400(Mondriaan's Dream)
#include <iostream>#include <cstring>using namespace std;int h, w;__int64 dp[12][1 << 12];//判断该行0的个数是否为偶数bool ok(int t){ int cnt = 0; //当前位之后0的个数 for (int i = 0; i < w...
2020-03-29 20:00:20 358
原创 HDU 1399(Starship Hakodate-maru)
基础题。#include <iostream>using namespace std;const int MAXA = 55;const int MAXB = 100;int main(){ int a[MAXA], b[MAXB]; //立方数,四面体数 for (int i = 0; i < MAXA; i++) { a[i] = i * i * ...
2020-03-29 11:33:54 126
原创 HDU 1398(Square Coins)
母函数题,套用标准模板即可。#include <iostream>using namespace std;const int MAXN = 305;int c1[MAXN], c2[MAXN];int main(){ int n; while (cin >> n) { if (n == 0) break; for (int i = ...
2020-03-29 10:39:59 139
原创 HDU 1397(Goldbach's Conjecture)
基础题,首先将小于 32768 的所有非素数标出,然后依次判断 i 和 n-i 是否均为素数即可。#include <iostream>using namespace std;const int MAXN = 32768;int prime[MAXN] = { 0 };int main(){ for (int i = 2; i < MAXN; i++) //...
2020-03-29 10:30:49 253
原创 HDU 1396(Counting Triangles)
基础题。#include <iostream>using namespace std;const int MAXN = 505;int num[MAXN];int main(){ num[1] = 1; for (int i = 2; i < MAXN; i++) { if (i % 2 == 1) num[i] = num[i - 1] + ...
2020-03-29 09:00:49 112
原创 HDU 1395(2^x mod n = 1)
基础题。#include <iostream>using namespace std;int main(){ int n; while (cin >> n) { if (n == 1 || n % 2 == 0) //n为1或偶数 cout << "2^? mod " << n << " = 1" <&...
2020-03-29 08:59:59 109
原创 HDU 1394(Minimum Inversion Number)
每次把序列的第一个数移到最后,形成一个新序列,求所有序列中最小的逆序数。由于序列之间有联系,所以不必每次重新求序列的逆序数,根据原序列的逆序数和原序列第一个数的逆序对数,能够求出下一个序列的逆序数。例如序列 3 4 1 2 0,首先求出原序列的逆序数,然后求出其第一个数 3 的逆序对数,3 后面比 3 小的数有1,2,0,所以其逆序对数 t=3,则其顺序对数为 n-1-t,n 为序列中数字...
2020-03-28 23:59:58 119
原创 HDU 1393(Weird Clock)
基础题,注意 s 的值是当前分针的位置,每次都会变动。#include <iostream>using namespace std;int main(){ int s, d; while (cin >> s >> d) { if (s == 0 && d == 0) break; int vis[60] = {...
2020-03-28 21:50:49 186
原创 HDU 1392(Surround the Trees)
求所有点的凸包,计算凸包的周长,注意只有一棵树和两棵树的情况。#include <iostream>#include <algorithm>#include <cmath>#include <iomanip>using namespace std;const int MAXN = 105;int cnt; //凸包中点的数量s...
2020-03-28 20:40:50 102
原创 HDU 1391(Number Steps)
基础题。#include <iostream>using namespace std;int main(){ int N; cin >> N; int x, y; while (N--) { cin >> x >> y; if (x == y) { if (y % 2 == 0) { cout ...
2020-03-28 20:00:20 119
原创 HDU 1390(Binary Numbers)
基础题。#include <iostream>using namespace std;int two[1000];int main(){ int d; cin >> d; while (d--) { int n; cin >> n; int index = 0; while (n != 0) { two[in...
2020-03-28 19:19:19 138
转载 HDU 1387(Team Queue)
#include <iostream>#include <map>#include <queue>#include <cstring>#include <string>using namespace std;const int MAXN = 1005;map<int, int> id; //元素编号-队列编号...
2020-03-28 17:20:29 177
原创 HDU 1385(Minimum Transport Cost)
本题使用Dijkstra算法,注意几个点:路径长度相同时,按照路径的字典序排序,注意要比较整条路经而不是单个结点; 输入起点和终点为同一个点时,不能输出 --> 符号。#include <iostream>#include <cstring>using namespace std;const int MAXN = 100;const int INF...
2020-03-28 10:40:00 157
转载 HDU 1384(Intervals)
#include <iostream>#include <algorithm>#include <cstring>#include <queue>using namespace std;const int MAXN = 50005;const int INF = 0x3f3f3f3f;struct Edge //边{ in...
2020-03-27 22:22:23 136
原创 HDU 1381(Crazy Search)
本题主要使用set 数据结构,在 set 中每个元素的值唯一,即向 set 中插入相同的元素,只保留一个。从前到后将所有子串插入 set,输出最终 set 中的元素数量即可。#include <iostream>#include <set>#include <string>using namespace std;set<string>...
2020-03-27 12:30:01 159
原创 HDU 1380(Nonstop Travel)
本题和 HDU 1344 完全相同。题目不难,注意几个点:绿灯、黄灯、红灯时间都是整型; 速度为整型,范围为 [30, 60]; 绿灯和黄灯都可以通过; 注意输出格式。#include <iostream>using namespace std;struct signal //信号灯{ double dis; //距停车场的距离(英里) int cycle; ...
2020-03-27 11:30:30 142
原创 HDU 1379(DNA Sorting)
基础题,主要是理解题意:一个字符串,对于每个字符,其后小于该字符的字符数量,称为该字符的逆序数,字符串中所有字符的逆序数之和称为该字符串的逆序数。首先求出题目中给定的所有字符串的逆序数,然后按照逆序数从小到大将字符串排序,输出。(注意如果两个字符串逆序数相同,则两者输出的先后顺序和输入时相同,使用 <algorithm> 中的 stable_sort 函数即可)#include ...
2020-03-27 11:22:34 140
原创 HDU 1376(Octal Fractions)
从低位向高位计算,例如 0.75[8] = ((5/8+7)/8)[10]#include <iostream>#include <cstring>using namespace std;const int MAXN = 1000;char s[MAXN];int ans[MAXN];int main(){ while (cin >&g...
2020-03-27 10:28:00 131
原创 HDU 1374(The Circumference of the Circle)
套用三点求圆公式即可。#include <iostream>#include <cmath>#include <iomanip>using namespace std;const double PI = 3.141592653589793;int main(){ double x1, y1, x2, y2, x3, y3; w...
2020-03-27 09:50:01 134
原创 HDU 1373(Channel Allocation)
计算最大团的结点数量,套用标准模板即可,详细见注释。#include <iostream>#include <string>#include <algorithm>#include <cstring>using namespace std;const int MAXN = 30;int n; //图中结点数量int ans; /...
2020-03-26 22:44:33 181
原创 HDU 1372(Knight Moves)
国际象棋中,骑士在一个 3*2 的格子中进行对角线移动,即可以朝八个方向移动,依次进行广搜即可。#include <iostream>#include <cstring>#include <queue>using namespace std;int dx[8] = { -2,-2,-1,-1,1,1,2,2 };int dy[8] = { 1,...
2020-03-26 18:30:00 182
转载 HDU 1370(Biorhythms)
#include<iostream>using namespace std;int main(){ int T; cin >> T; while (T--) { int Case = 1; int a, b, c, d; while (cin >> a >> b >> c >> d) { ...
2020-03-26 17:30:01 109
转载 HDU 1112(The Proper Key)
#include <iostream>#include <cstring>using namespace std;bool key[105][105], lock[10005][1005]; //钥匙,锁bool visit[10005][1005];int R, C; //钥匙的边长int D, W; //锁的边长bool in(int y){ i...
2020-03-26 13:00:00 186
原创 HDU 1364(Illusive Chase)
深搜题,题意:地图中 0 代表空地,1 代表障碍物,每一步的信息包括最小步长,最大步长,方向,从地图中某一个格子出发,依次按照每一步的信息前进,如果走完所有步仍没有出界或者碰到障碍物,则代表该格子可行,求地图中这种格子的数量。依次对每一个格子深搜,判断从其出发,能否走完所有步,详细见注释。#include <iostream>using namespace std;in...
2020-03-26 11:30:01 159
转载 HDU 1362(The Bermuda Triangle)
#include <iostream>#include <vector>#include <algorithm>#include <cstring>using namespace std;int s, n;vector<int> small; //小三角形的边长bool vis[110][110]; //访问情况//...
2020-03-25 23:00:30 207
原创 HDU 1361(Parencodings)
基础题,首先根据 P 序列生成括号序列,再根据括号序列生成 W 序列。#include <iostream>#include <cstring>using namespace std;int bracket[10000]; //括号序列(-1表示左括号,1表示右括号)int P[25], W[25]; //P序列,W序列int main(){ int...
2020-03-25 21:30:30 102
原创 HDU 1360(Spell checker)
基础题,依次按要求判断每一个字符即可。#include <iostream>#include <cctype>using namespace std;int main(){ int mistake = 0; //错误数 bool isSenFirst = true; //是否为句子的第一个字符 bool isWordFirst = true; //是否...
2020-03-25 20:40:00 122
转载 HDU 1358(Period)
#include <iostream> using namespace std;const int MAXN = 1000005;char Str[MAXN];int Next[MAXN];int n;void KMP(){ int i = -1, j = 0; Next[0] = -1; while (j < n) { if (i == -1 ...
2020-03-25 18:50:00 123
转载 HDU 1356(The Balance)
#include <iostream>#include <algorithm>using namespace std;const int INF = 1e9 + 5;__int64 exgcd(__int64& x, __int64& y, int a, int b){ if (b == 0) { x = 1; y = 0; r...
2020-03-23 17:30:31 151
原创 HDU 1355(The Peanuts)
基础题。#include <iostream>#include <algorithm>#include <cmath>using namespace std;const int MAXN = 55;struct Node //花生田的结点{ int x, y; //坐标 int num; //花生数}node[MAXN * MAXN];...
2020-03-23 14:50:31 131
原创 HDU 1354(Choose Your Own Adventure)
深搜题,由于从第 1 行开始,且通往 "HAPPY" 行的路径唯一,所以从 "HAPPY" 行开始深搜,直到到达第 1 行,然后从第 1 行开始输出路径中的行的文本即可。#include <iostream>#include <string>#include <cstring>using namespace std;int X; //总行数s...
2020-03-23 11:33:56 278
原创 HDU 1353(Exact Change Only)
暴力搜索即可,注意比较 double 大小要借助 eps,不能直接比较。#include <iostream>#include <cmath>using namespace std;const double eps = 1e-8;int main(){ double sum; int A, B, C, D; int a, b, c, d; whil...
2020-03-22 22:44:22 359
QT、C++ 米其林自助点餐系统
2016-11-16
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人