递归问题 研究

汉诺塔问题 #include<iostream> using namespace std; int cnt; void hanoi(int n, char from, char by, char to){ if(n==1){ cout<<"move "<<n<<" "<<from<&
分类: 其他 发布时间: 08-30 23:34 阅读次数: 0

冒泡排序问题

Problem 9 普通题(simple) 问题描述 老韩让书名号出一道简单题,于是他出了n道题(1-n),让鱼人们去做,并让它们给出每道题的普通指数ai,你能帮帮书名号,帮他把题目按照普通度排序么? 一句话题意:给出n个权值,按照权值从小到大将编号排序。 数据保证权值不重复。 输入格式 第一行一个整数n,代表题目的数量。 第二行n个数字,代表每道题的权值。 输出格式 一行,数...
分类: 其他 发布时间: 08-30 23:34 阅读次数: 0

暑期测试2 题目积累中

类型1 求素数 例1,1 素数个数统计 ,统计100到300之间素数共有多少个,计算所有素数的和并输出结果 时间复杂度o(n2) #include <stdio.h> void main() { int i,j,n=0,sum=0; for(i=100;i<=300;i++) { for(j=2;j<i;j++)
分类: 其他 发布时间: 08-30 23:33 阅读次数: 0

第二测 3小时

1题目背景 从哪里跌倒就要从哪里爬起来!!! 上次给学弟学妹们出进制转换,居然没有一个人AC!于是这一次,心情绝望的学长决定出一回水水的进制转换作为这场考试的第一道水题。 (当然,也可能是唯一一道) 题目描述 作为迷你版进制转换,测试数据将给出一个十进制数据,你只需要编写程序输出这个十进制数据的二进制,八进制和十六进制表示。 注意:十六进制中10至15分别由A,B,C,D,E,F六个大...
分类: 其他 发布时间: 08-30 23:33 阅读次数: 0

sort 排序

问题背景 老韩让书名号出一道普通题,于是他出了nn道题(1−n)(1−n),让鱼人们去做,并让它们给出每道题的普通指数aiai,你能帮帮书名号,帮他把题目按照普通度排序么? 与上次不同的是,如果普通指数相同,你需要按照编号从大到小排列。 输入格式 第一行一个整数nn,代表题目的数量。 第二行nn个数字,代表每道题的普通指数。 输出格式 一行nn个数,代表排序好的题目编号(请不要在末尾留空...
分类: 其他 发布时间: 08-30 23:33 阅读次数: 0

排序经典题

问题描述 明明想在学校中请一些同学一起做一项问卷调查,为了实验的客观性,他先用计算机生成了 NN 个 1 到 1000 之间的随机整数(N≤100N≤100),对于其中重复的数字,只保留一个,把其余相同的数去掉,不同的数对应着不同的学生的学号。然后再把这些数从小到大排序,按照排好的顺序去找同学做调查。请你协助明明完成“去重”与“排序”的工作。 输入格式 第 1 行为 1 个正整数,表示所生成...
分类: 其他 发布时间: 08-30 23:33 阅读次数: 0

在线数学公式编辑

http://latex.91maths.com/ sin\alpha +cos\beta=\frac{1}{2} sinα+cosβ=1/2
分类: 其他 发布时间: 08-30 23:32 阅读次数: 0

UVA 10891 Game of Sum——dp

定义dp[i][j]表示面对区间[i,j]的数执先手一方可获得的最大数字和 注意题目描述貌似不太严谨,差距可以是负的,一开始加绝对值错了。。。 #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; ty...
分类: 其他 发布时间: 08-30 23:32 阅读次数: 0

HDU 6415 Rikka with Nash Equilibrium——dp

#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; typedef long long ll; const int maxn = 81; int T, n, m, mod; ll dp[2][maxn][...
分类: 其他 发布时间: 08-30 23:32 阅读次数: 0

UVA 11825 Hackers' Crackdown——dp

#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; int kase, n, a[20], un[1<<16], dp[1<<16]; int main() { while...
分类: 其他 发布时间: 08-30 23:31 阅读次数: 0

UVA 10859 Placing Lampposts——dp

#include <cstdio> #include <vector> #include <cstring> #include <iostream> #include <algorithm> using namespace std; const int maxn = 1010; int T, n, m; bool vi...
分类: 其他 发布时间: 08-30 23:31 阅读次数: 0

HDU 6434 Problem I. Count

#include<bits/stdc++.h> using namespace std; #define LL long long const int N = 2e7; const int maxn = N+10; int T,n; int primes,prime[maxn],phi[maxn]; bool vis[maxn]; LL ans[maxn]; void init...
分类: 其他 发布时间: 08-30 23:30 阅读次数: 0

UVALive 3983 Robotruck——单调队列优化dp

注意一下一开始要把原点入队 #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <cmath> using namespace std; const int maxn = 1e5 + 10; int T, C, n...
分类: 其他 发布时间: 08-30 23:30 阅读次数: 0

HDU 5887 Herbs Gathering——剪枝

#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; typedef long long ll; const int maxn = 1e5 + 10; ll N, V, MAX; struct Data {...
分类: 其他 发布时间: 08-30 23:30 阅读次数: 0

UVALive 4794 Sharing Chocolate——dp

#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; bool judge[(1<<15)+10]; int kase, N, X, Y, a[20], sum[(1<<15)+10...
分类: 其他 发布时间: 08-30 23:30 阅读次数: 0

HDU 5884 Sort——二分+O(n)哈弗曼树

两个队列搞一搞就搞出O(n)的哈弗曼树了 #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; typedef long long ll; const int maxn = 1e5 + 10; char ...
分类: 其他 发布时间: 08-30 23:29 阅读次数: 0

HDU 5883 HDU - 5883——欧拉路

注意判一下欧拉回路的情况,这种情况下需要找一个点再异或一次 #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; const int maxn = 1e5 + 10; const int maxm = 1...
分类: 其他 发布时间: 08-30 23:29 阅读次数: 0

HDU 5886 Tower Defence——dp

预处理出最长链,若断边不在最长链上,那么答案依旧是最长链,否则计算断开后的最长链,这个做一次树形dp就可以了 #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; typedef long long ll...
分类: 其他 发布时间: 08-30 23:29 阅读次数: 0

UVALive 4256 Salesmen——dp

#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <vector> using namespace std; const int INF = 0x3f3f3f3f; int T, n, m, L, a[210]; ...
分类: 其他 发布时间: 08-30 23:29 阅读次数: 0

UVA 11552 Fewest Flops——dp

注意当前块结尾字符若等于前一个块的结尾字符,要判一下当前块的字符总数是否为1 #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; const int maxn = 1010; const int INF...
分类: 其他 发布时间: 08-30 23:28 阅读次数: 0