- 博客(32)
- 收藏
- 关注
原创 1096. Consecutive Factors (20)
IDEA1.从2开始到n开方,作为连续因子的第一个进行检查2.环条件写i*iCODE#include#include#includeusing namespace std;int main(){ #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); #endif int n; cin>>n; int
2016-06-30 10:21:10 223
原创 1030. Travel Plan (30)
IDEA1.求最短路径,并输出该路径2.要就在判断过程中若存在相同长度,则选cost小的3.Dijkstra改进CODE#include#include #include#includeusing namespace std;#define Max 500#define INF 0x6FFFFFFFstruct Edge{ int end; int
2016-06-28 10:54:03 383
原创 1049. Counting Ones (30)
IDEA1.分别考虑每一位出现1的情况,将其相加循环考虑当前位,高位,低位如果当前位==0,则该为出现1 的情况由更高位决定,= 更高为数字*当前位数如果当前位==1,则该为出现1 的情况受更高位以及低位影响,= (更高为数字*当前位数)+(低位数字+1)如果当前位>1,则该为出现1 的情况由更高位决定,= (更高为数字+1)*当前位数CODE#includ
2016-06-27 10:26:38 580
原创 1055. The World's Richest (25)
IDEA1.测试点二容易超时,所有的cin,cout该为scanf和printf;2.用scanf输入string类型#include #include using namespace std;int main(){ string a; a.resize(100); //需要预先分配空间 scanf("%s", &a[0]); puts(a.c_str()); ret
2016-06-27 09:31:04 377
原创 1056. Mice and Rice (25)
IDEA1.需要vector:programer,order,used(初始化为0),used值为1的不进入下一轮2.计算分组数:np%ng==0?group=np/ng:group=np/ng+1; 以group为循环依据group%ng==0?group=group/ng:group=group/ng+1;group==1则下一次不在循环3.计算每组的最大值,记录其id,并给
2016-06-24 10:54:28 219
原创 1062. Talent and Virtue (25)
IDEA1.简单的结构体排序问题;2.注意用cin,cout作为输入输出会超时,要改用scanf,printf;CODE#include#include#include #include#include#includeusing namespace std;struct Person{ //string id; int id; int virtue;
2016-06-23 23:04:29 182
原创 1071. Speech Patterns (25)
IDEA1.isalnum()判断是否为字母或者数字2.stringsteam ss; ssword=ss.str();//将缓冲流ss中的字符串写入到word中 ss.str("");清空缓冲流中内容3.transform(first,last,result,op);CODE#include#include#include #include#include
2016-06-22 16:05:28 185
原创 1070. Mooncake (25)
IDEA1.首先n和d为正整数,分别表示月饼数和需求量;第二行是每种月饼的库存,为正数,不一定是正数,用float型;2.可能存在总库存小于需求d的情况CODE#include#include #include#include#includeusing namespace std;#define Max 1001struct Cake{ float nu
2016-06-22 12:01:25 193
原创 1069. The Black Hole of Numbers (20)
IDEA1.输入的正整数在(0-10000),如果输入小于4位,则补零补齐4位,在哪个位置没有关系,反正需要排序2.如果结果为0000或者6174,则循环继续 CODE#include#include#include#include#includeusing namespace std;int cmp1(int a,int b){ return a>b;//降
2016-06-22 11:25:15 221
原创 1053. Path of Equal Weight (30)
IDEA1.树的存储 vector > vec2.树的深度遍历DFS,输出遍历路径3.vector的方法,back()返回最末元素pop_back()移除最后一个元素CODE#include#include #include#includeusing namespace std;#define Max 110int s;int weight[Max];
2016-06-21 10:47:02 352
原创 1052. Linked List Sorting (25)
IDEA1.如果start address==-1,则直接输出 0 -1,不用再执行下面操作,如果执行了会数组越界CODE#include#include#include #include #include#includeusing namespace std;#define Max 100000struct Node{ int add; int key;
2016-06-20 22:19:10 166
原创 1078. Hashing (25)
IDEA1.二次探测法: hi=(h(key)+i*i)%m 0≤i≤m-1,即即探查序列为d=h(key),d+1^2,d+2^2,…2.判断是否为素数CODE#include#include #include#include#includeusing namespace std;#define Max 10010int table[Max],tsize;
2016-06-20 10:45:22 162
原创 map排序方法
map的进行排序:1.key排序是默认的,从小到大默认排序2.value需要借助vector进行排序,首先把map中数据放到vector中,然后利用sort对vector排序struct User{ int score[MaxK]; int sum; int full_cnt; int rank;};map record;vectorpair > result;
2016-06-19 09:46:45 2332
原创 map的erase函数用法与注意
map record; map::iterator it; it=record.begin(); while(it!=record.end()){ int flag=-1; for(int i=0;i<k;i++){ flag=0; } if(flag){ record.erase(it++); }else{ it++; }
2016-06-19 09:36:15 3874
原创 1075. PAT Judge (25)
The ranklist of PAT is generated from the status list, which shows the scores of the submittions. This time you are supposed to generate the ranklist for PAT.Input Specification:Each input fil
2016-06-19 09:23:04 378
原创 1074. Reversing Linked List (25)
Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, if K = 3, then you must output 3→2→1→6→5→4; if K
2016-06-18 11:00:50 200
原创 1073. Scientific Notation (20)
Scientific notation is the way that scientists easily handle very large numbers or very small numbers. The notation matches the regular expression [+-][1-9]"."[0-9]+E[+-][0-9]+ which means that the in
2016-06-17 10:01:37 246
原创 1076. Forwards on Weibo (30)
Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social network is formed with followers relations. When a
2016-06-16 10:58:11 204
原创 1077. Kuchiguse (20)
The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality. Such a preference is called
2016-06-16 09:45:40 157
原创 1065. A+B and C (64bit) (20)
Given three integers A, B and C in [-263, 263], you are supposed to tell whether A+B > C.Input Specification:The first line of the input gives the positive number of test cases, T (Output
2016-06-15 09:32:33 182
原创 1063. Set Similarity (25)
Given two sets of integers, the similarity of the sets is defined to be Nc/Nt*100%, where Nc is the number of distinct common numbers shared by the two sets, and Nt is the total number of distinct num
2016-06-13 11:10:06 179
原创 1061. Dating (20)
Sherlock Holmes received a note with some strange strings: "Let's date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm". It took him only a minute to figure out that those strange strings are a
2016-06-13 09:13:20 215
原创 1060. Are They Equal (25)
If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as 0.123*105 with simple chopping. Now given the number of significa
2016-06-12 10:54:12 229
原创 1059. Prime Factors (25)
Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p1^k1 * p2^k2 *…*pm^km.Input Specification:Each input file contains one test c
2016-06-12 09:36:34 168
原创 1080. Graduate Admission (30)
It is said that in 2013, there were about 100 graduate schools ready to proceed over 40,000 applications in Zhejiang Province. It would help a lot if you could write a program to automate the admissio
2016-06-06 12:03:35 205
原创 1097. Deduplication on a Linked List (25)
Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K, only the first node of which the value or a
2016-06-05 12:17:23 175
原创 1085. Perfect Sequence (25)
Given a sequence of positive integers and another positive integer p. The sequence is said to be a "perfect sequence" if M Now given a sequence and a parameter p, you are supposed to find from the
2016-06-04 11:02:23 187
原创 1047. Student List for Course (25)
Zhejiang University has 40000 students and provides 2500 courses. Now given the registered course list of each student, you are supposed to output the student name lists of all the courses.Input S
2016-06-03 10:34:06 217
原创 1043. Is It a Binary Search Tree (25)
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node's key.The right
2016-06-02 23:03:24 193
原创 1086. Tree Traversals Again (25)
An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys numbered from 1 to 6) is traversed, the stac
2016-06-02 16:20:33 262
原创 1064. Complete Binary Search Tree (30)
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node's key.The right
2016-06-01 22:21:54 245
原创 1099. Build A Binary Search Tree (30)
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node's key.The right
2016-06-01 12:13:38 194
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人