- 博客(63)
- 资源 (4)
- 收藏
- 关注
原创 1:密码翻译
题目链接:http://dsalgo.openjudge.cn/huawen03/1/直接模拟。注意z和Z用a和A替代。#include #include #include using namespace std;int main(){ int n; string s; while(~scanf("%d\n",&n)) { w
2017-10-10 20:00:40 1037
原创 3:十进制数转二进制数(类似大整数除法)
题目链接:http://dsalgo.openjudge.cn/huawen02/3/题目大意就是将十进制数转换成二进制,难就难在十进制数的位数小于100位。这就意味着不能用任意类型来存,只能用数组来存。十进制转二进制十进制转二进制 十进制整数转换为二进制整数采用"除2取余,逆序排列"法。 具体做法是:用2整除十进制整数,可以得到一个商和余数;再用2去除商,又会得到一个商和余数,如此进
2017-10-10 16:28:26 3396
原创 约瑟夫问题
题目链接:http://dsalgo.openjudge.cn/huawen02/1/1. 题目给的数据范围不大可以直接用数组来模拟。2. 约瑟夫问题还可以用递推的方式求得。f(n)表示数据为[o,n-1]时的最后剩下的元素是谁,也就是能从前一个f(n-1)得到f(n)。递推式:(f(n-1)+m)%n = f(n)。//直接模拟#include #include #incl
2017-10-01 20:07:52 285
原创 多项式加法
题目地址:http://dsalgo.openjudge.cn/huawen02/2/本来打算直接用数组直接模拟,后来发现越写越复杂。最后打算数据用一个单向链表来存。1. 定义一个投节点pHead。2. 每次新增加的节点存在pHead节点后。3. 对链表的元素进行排序,只改节点中的值而不是移动具体节点。4. 注意第一行可能存在 (如3 5 6 2 6 5 9 -8) 这样的
2017-10-01 18:56:31 460
原创 hdu 1863(prim&kruskal)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1863prim:#include #include #include using namespace std;#define INF 0x3fffffffint graph[101][101];int visit[101];int flag[101];int sum;int n
2015-10-19 12:09:06 470
原创 UVA 1586 - Molar mass
#include #include int key[5];double value[5]={0,12.01,1.008,14.01,16.00};int T;int num=0,p=0,flag=0;int check(char ch){ switch(ch) { case 'C': return 1; case 'H':
2014-10-22 17:44:24 822
原创 计算器(Java)
第一个Java程序。。import java.awt.Button;import java.awt.Dimension;import java.awt.FlowLayout;import java.awt.Frame;import java.awt.GridLayout;import java.awt.TextField;import javax.swing.JLabel;imp
2014-06-08 14:17:56 787
原创 Codeforces Round #230 (Div. 2)B. Three matrices
题目连接:http://codeforces.com/problemset/problem/393/B#include #include double w[171][171];double a[171][171];double b[171][171];int n;int main(){ int i,j; while(~scanf("%d",&n)
2014-02-19 00:10:56 775
原创 Codeforces Round #230 (Div. 2) A. Nineteen
题目连接:http://codeforces.com/problemset/problem/393/A#include #include using namespace std;#include #include #include char stu[200];int main(){ int i; while(~scanf("%s",stu)) {
2014-02-19 00:09:24 749
原创 poj 2492 A Bug's Life
题目链接:http://poj.org/problem?id=2492 把父亲初始化为自己要比初始化为-1的要快,1,要想男女分开,必须找到的祖先是不同的。2,(1),如果祖先相同就矛盾了,flag=1; (2), x,y都没对象。 (3), x没对象,y有对象。 (4), x,y都有对象。 (5), x
2014-02-18 00:34:10 578
原创 poj 2524 Ubiquitous Religions
题目链接:http://poj.org/problem?id=2524并查集的模版题:#include #include struct node{ int pre; int rankk;};node stu[50010];int n,m;int find(int x){ int r=x; while(stu[r].pre!=-1)
2014-02-16 22:48:41 602
原创 codeforces Rockethon 2014 A
题目连接:http://codeforces.com/contest/395/problem/A2set:#include #include using namespace std;#include #include #define INF 0x3fffffffint n,q;int main(){ int i,x,y,ans; while(~scanf("
2014-02-16 03:43:21 686
原创 poj 1611The Suspects
题目连接:http://poj.org/problem?id=1611并查集的模版题:#include #include struct node{ int pre; int rankk;};node stu[30010];int n,m,k;int find(int x){ int r=x; while(stu[r].pre!=-1)
2014-02-16 03:35:38 603
原创 HDU1863畅通工程
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1863这题你把村庄数定义到100就是wa,估计数据大于等于100了。。。#include #include #define INF 0x3fffffffint m,n;int graph[110][110];bool visit[110];int dis[110];int sum;
2014-02-15 15:27:09 667
原创 HDU 1233还是畅通工程
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1233prim算法:#include #include #define INF 0x3fffffffint n;int graph[100][100];bool visit[100];int dis[100];int sum;void prim(){ int i,j;
2014-02-15 02:09:08 620
原创 杭电1800Flying to the Mars
Flying to the MarsTime Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9138 Accepted Submission(s): 2978Problem DescriptionIn th
2014-02-15 00:09:58 816
原创 HDU 4287 Intelligent IME
Intelligent IMETime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1949 Accepted Submission(s): 956Problem Description We all use ce
2014-02-14 19:57:01 688
原创 HDU 2275 Kiki & Little Kiki 1
Kiki & Little Kiki 1Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 713 Accepted Submission(s): 238Problem DescriptionKiki is con
2014-02-14 01:57:49 634
原创 vector操作
vector(向量)vector是 连续内存 容器#include #include using namespace std;int main(){ vector v; v.push_back(1); //push_back v.push_back(7); v.push_back(10); v.
2014-02-13 00:46:07 622
原创 priority_queue操作
优先队列和堆的操作基本相同。优先队列只不过比堆多了一个接口,就是获得优先级最高的值。位于堆顶的元素一般是优先级别最高的,而且插入数据需要重新排列的复杂度为O(lgn)。#include #include #include using namespace std;#include #include struct cmp{ int operator ()(char a,cha
2014-02-12 21:19:40 674
原创 queue操作
先进先出#include #include #include #include using namespace std;struct node{ int x; char a[10];};int main(){ //queue q1; queue q; //queue q2; //queue q3; //queue q4;
2014-02-12 18:16:44 687
原创 stack操作
stack可以用数组或链表来实现。先进后出。#include using namespace std;#include #include #include #include #include struct node{ char a[10]; string b;};int main(){ stack s1; /*stack s2;
2014-02-12 16:37:43 1033
原创 multiset操作
1,multiset多重集合容器使用RB-Tree的平衡二叉检索树的数据结构。2,multiset和multimap一样可以重复的3,erase删除所有相同的4,find返回指向第一个的迭代器。#include #include using namespace std;#include struct node{ int x,y;};int main(){
2014-02-12 04:04:50 995
原创 set操作
集合通过一个链表来组 织,在插入操作和删除操作上比向量(vector)快,但查找或添加末尾的元素时会有些慢。#include #include #include using namespace std;int main(){ // set s1; //定义 // set s2; set s; // set s4; // set s5;
2014-02-12 03:27:04 617
原创 Codeforces Round #229 (Div. 2) B. Inna, Dima and Song
B. Inna, Dima and Songtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputInna is a great piano player and Dima
2014-02-12 02:35:14 807
原创 Codeforces Round #229 (Div. 2) Inna and Alarm Clock
A. Inna and Alarm Clocktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputInna loves sleeping very much, so sh
2014-02-12 02:32:03 754
原创 multimap操作
1,multimap与map大致相同。 (1),insert不同; (2),允许有相同关键字的,输出按顺序输出。2,find()相同的返回指向第一个迭代器。3,erase()删除相同的所有。 #include using namespace std;#include #include #include int main(){ /*
2014-02-11 23:17:08 788
原创 map操作
注意:map有去重功能,以最后一个为准。map有自动排序功能,不能用sort。map的swap有两种交换。map的count函数返回只有0或1,只有multimap中是0,1,>1多种。1,map类型的创建:map maps;其中a,b可以由string,char,int相互组合,一共6个。2,map类型的插入:最简单的是:如: map maps1
2014-02-11 15:48:42 996
原创 HDU 1075 What Are You Talking About
What Are You Talking AboutTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 102400/204800 K (Java/Others)Total Submission(s): 11638 Accepted Submission(s): 3722Problem Description
2014-02-10 02:03:04 789
原创 09湘潭赛
猜想Time Limit 3000msMemory Limit 65536Kdescription哥德巴赫(Goldbach ]C.,1690.3.18~1764.11.20)是德国数学家;出生于格奥尼格斯别尔格(现名加里宁城);曾在英国牛津大学学习;原学法学,由于在欧洲各国访问期间
2014-02-10 01:53:00 1013
原创 HDU1305 Immediate Decodability
Immediate DecodabilityTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1567 Accepted Submission(s): 792Problem DescriptionAn encod
2014-02-09 01:07:57 573
原创 HDU 1857Word Puzzle
Word PuzzleTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 469 Accepted Submission(s): 83Problem DescriptionDid you heard of a li
2014-02-08 23:45:52 661
原创 HDU 3460Ancient Printer
Ancient PrinterTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 1054 Accepted Submission(s): 495Problem DescriptionThe contest is
2014-02-05 21:04:04 627
原创 Codeforces Round #228 (Div. 2)C. Fox and Box Accumulation
C. Fox and Box Accumulationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFox Ciel has n boxes in her room
2014-02-04 23:04:59 622
原创 Codeforces Round #228 (Div. 2)B. Fox and Cross
B. Fox and Crosstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFox Ciel has a board with n rows and n colu
2014-02-04 23:01:28 599
原创 Codeforces Round #228 (Div. 2)A. Fox and Number Game
A. Fox and Number Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFox Ciel is playing a game with numbe
2014-02-04 22:59:31 613
原创 杭电3724
Encoded BarcodesTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1508 Accepted Submission(s): 530Problem DescriptionAll the big ma
2014-02-03 02:59:34 545
原创 杭电1800
Flying to the MarsTime Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9103 Accepted Submission(s): 2960Problem DescriptionIn th
2014-02-02 03:04:46 732
原创 杭电2846
RepositoryTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2109 Accepted Submission(s): 779Problem DescriptionWhen you go shopping
2014-02-01 18:31:31 564
原创 杭电1671字典树
Phone ListTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 8253 Accepted Submission(s): 2833Problem DescriptionGiven a list of pho
2014-01-30 20:21:46 551
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人