水题水一波、

昨晚被dp搞的不轻、最气的是看题解都看不懂、

本想今天拿水题来练练手感、

结果我发现我错了、!!!

总结一下自己的错误把、   真希望错过的东西都不要在错了、

HDU 1070 Milk

题意:就是一个人去超市买牛奶、给你一些牛奶的牌子 价钱 容量,牛奶的保质期是6天、并且每天喝200ml,如果某种牛奶的容量小于200ml 这种牛奶直接就被拉黑了,并且保证所有的牛奶都是当日产的,要你求买那种牛奶最便宜,而且他只会买一瓶牛奶、上面给出的各种品牌的牛奶都是一瓶的价格容量,如果有多种牛奶同样便宜,要求输出容量大的、

思路:不难,但是题意说的很罗嗦,就是求每升牛奶的价格最低的那一个、 但是这里有个细节,就是那些容量超过1200ml的牛奶的处理,因为他只会喝1200ml 所以就算你容量再多也是多余的、  超过的部分直接舍去

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<cmath>
 4 const int qq=150;
 5 struct Milk
 6 {
 7     char s[150];
 8     int p;
 9     int v;
10 }milk[qq];
11 int partition(int l,int r)
12 {
13     int i,j;
14     Milk x=milk[l];
15     i=l;j=r;
16     while(1){
17         while(i<j && milk[j].v>=x.v)    --j;
18         milk[i]=milk[j];
19         while(i<j && milk[i].v<=x.v)    ++i;
20         milk[j]=milk[i];
21             if(i>=j)    break;
22     }
23     milk[i]=x;
24     return i;
25 }
26 void quick(int l,int r)
27 {
28     if(l<r){
29         int temp=partition(l,r);
30         quick(l,temp-1);
31         quick(temp+1,r);
32     }
33 }
34 int main()
35 {
36     int t;scanf("%d",&t);
37     while(t--){
38         int n;scanf("%d",&n);
39         char str[150];
40         int x,y;int count=0;
41         for(int i=0;i<n;++i){
42             scanf("%s%d%d",str,&x,&y);
43             if(y<200)    continue;
44             strcpy(milk[count].s,str);
45             milk[count].p=x;
46             milk[count++].v=y;
47         }
48         quick(0,count-1);    //排序一下 从容量大往容量小去比较、
49         Milk cheap=milk[count-1];
50         if(cheap.v>=1200)
51             cheap.v=1200;
52         for(int i=count-2;i>=0;--i){
53             if(milk[i].v>=1200)
54                 milk[i].v=1200;
55             if(cheap.p*1.0/cheap.v*1200>milk[i].p*1.0/milk[i].v*1200)
56                 cheap=milk[i];
57         }
58         printf("%s\n",cheap.s);
59     }
60     return 0;
61 } 

HDU 1062 Text Reverse

题意:就是将所有单词反转过来按英语作文的方式输出

这题有点坑阿、  我自己写了几种做法都WA了、  但是我就是不知道错在哪里、

先贴一个对的、  这种做法就直接对每一个单词进行输出

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<stack>
 4 using namespace std;
 5 char s[2000];
 6 int blank[1020];
 7 int main()
 8 {
 9     int t;scanf("%d",&t);
10     getchar();
11     while(t--){
12         memset(blank,0,sizeof(blank));
13         gets(s);
14         int count=1;
15         blank[0]=-1;
16         int len=strlen(s);
17         s[len]=‘ ‘;
18         s[len+1]=‘\0‘;
19           for(int i=0;i<=strlen(s);++i)
20               if(s[i]==‘ ‘)
21                   blank[count++]=i;
22           for(int i=1;i<count;++i){
23               for(int j=blank[i]-1;j>=blank[i-1]+1&&s[j]!=‘ ‘;--j)  // 不加s[j]!=‘ ‘ 会WA,我也不知道为什么
24                   printf("%c",s[j]);                    // 我自己想是觉得不用加的、
25               if(i!=count-1)    printf(" ");
26         }
27         printf("\n");
28     }
29     return 0;
30 }

HDU 1019 Least Common Multiple

这题是真的水、 一发A了、 只需要注意数据不溢出就行了、  那么就先进行除法嘛

题意:求多个数的最大公倍数、

思路:你想想如果你能求出其中两个数的最大公倍数、那么n个数的最大公倍数是肯定大于等于这两个数的最大公倍数的、

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<cmath>
 4 #include<algorithm>
 5 using namespace std;
 6 const int qq=50000;
 7 int gcd(int a,int b)
 8 {
 9     return b==0?a:gcd(b,a%b);
10 }
11 int num[qq];
12 int main()
13 {
14     int t;scanf("%d",&t);
15     while(t--){
16         int n;scanf("%d",&n);
17         for(int i=0;i<n;++i)
18             scanf("%d",&num[i]);
19         if(n==1){
20             printf("%d\n",num[0]);
21             continue;
22         }
23         if(num[0]<num[1]){
24             num[0]=num[0]+num[1];
25             num[1]=num[0]-num[1];
26             num[0]=num[0]-num[1];
27         }
28         int maxn=num[0]/gcd(num[0],num[1])*num[1];
29         for(int i=2;i<n;++i){
30             if(num[i]>maxn)    maxn=max(maxn,maxn/gcd(num[i],maxn)*num[i]);
31             else            maxn=max(maxn,maxn/gcd(maxn,num[i])*num[i]);
32         }
33         printf("%d\n",maxn);
34     }
35 }
时间: 2024-08-24 01:55:26

水题水一波、的相关文章

ACM_输出格式(水题)

输出格式 Time Limit: 2000/1000ms (Java/Others) Problem Description: 某水比参加了XX杯,但是他太水,所以三等都木有,所以他决定出一道水题水一水. Input: 输入多组测试数据,每一组一个整数width(3-50),一个整数height(3-50),一个字符串(长度不超过width-2). Output: 对于每个测试实例,要求把字符串按要求输出(字符串处于由width为长,height为宽的矩形的中部), (...倘若不能完全对称,请

2015南阳CCPC L - Huatuo&#39;s Medicine 水题

L - Huatuo's Medicine Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description Huatuo was a famous doctor. He use identical bottles to carry the medicine. There are different types of medicine. Huatuo put medicines into the bottles and chain these b

sdut 2841 Bit Problem (水题)

题目 贴这个题是因为看题解有更简单的方法, 我做的时候是直接算的, 也很简单. 贴一下题解吧: 如果一个整数不等于 0,那么该整数的二进制表示中至少有一位是 1. 这个题结果可以直接输出 x - (x&(x-1)); 因为x-1 之后二进制下,就是最右边的1变成了0, 最右边的1的 右边所有的0变成了1, 不影响最左边. 我的代码: 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4

sdut 2413:n a^o7 !(第三届山东省省赛原题,水题,字符串处理)

n a^o7 ! Time Limit: 1000MS Memory limit: 65536K 题目描述 All brave and intelligent fighters, next you will step into a distinctive battleground which is full of sweet and happiness. If you want to win the battle, you must do warm-up according to my inst

杭电(hdu)2053 Switch Game 水题

Switch Game Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 13113    Accepted Submission(s): 7970 Problem Description There are many lamps in a line. All of them are off at first. A series of o

4.7-4.9补题+水题+高维前缀和

题目链接:51nod 1718 Cos的多项式  [数学] 题解: 2cosx=2cosx 2cos2x=(2cosx)^2-2 2cos3x=(2cosx)^3-3*(2cosx) 数归证明2cos(nx)能表示成关于2cosx的多项式,设为f(n) f(1)=x,f(2)=x^2-2(其中的x就是2cosx) 假设n=1~k时均成立(k>=3) 当n=k+1时 由cos((k+1)x)=cos(kx)cos(x)-sin(kx)sin(x) cos((k-1)x)=cos(kx)cos(x)

历年NOIP水题泛做

快noip了就乱做一下历年的noip题目咯.. noip2014 飞扬的小鸟 其实这道题并不是很难,但是就有点难搞 听说男神错了一个小时.. 就是$f_{i,j}$表示在第$i$个位置高度为$j$的时候最小点击次数 递推的话对于上升的情况只做一次,后面几次在后面再做.. #include <cstdio> #include <cstring> #include <cstdlib> #include <algorithm> using namespace st

[ZPG TEST 114] 阿狸的英文名【水题】

1.      阿狸的英文名 阿狸最近想起一个英文名,于是他在网上查了很多个名字.他发现一些名字可以由两个不同的名字各取一部分得来,例如John(约翰)的前缀 "John"和Robinson(鲁滨逊)的后缀 "son" 连在一起就是Johnson. 现在他找到了两个喜欢的名字(名字可看作字符串),用A和B表示,他想知道取A的一个非空前缀和B的一个非空后缀,连接在一起能组成多少不同的字符串. 输入格式 输入两行,分别表示字符串A和B:字符串只包含小写英文字母. 输出格

G - Brain Network (easy)(并查集水题)

G - Brain Network (easy) Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u CodeForces 690C1 Description One particularly well-known fact about zombies is that they move and think terribly slowly. While we still don't know