Description
There are some students in a class, Can you help teacher find the highest student .
Input
There are some cases. The first line contains an integer t, indicate the cases; Each case have an integer n ( 1 ≤ n ≤ 100 ) , followed n students’ height.
Output
For each case output the highest height, the height to two decimal plases;
Sample Input
2 3 170.00 165.00 180.00 4 165.00 182.00 172.00 160.00
Sample Output
180.00 182.00
//水题
#include<stdio.h> int main() { int a,c,k,i; double b; double MAX=0.0; scanf("%d",&c); for(k=1;k<=c;k++) { double max=0.0; scanf("%d",&a); for(i=1;i<=a;i++) { scanf("%lf",&b); if(max<b) max=b; MAX=max; } printf("%.2lf\n",MAX); } return 0; }
#include<stdio.h> #include<string.h> int main() { int i,x,y,c,d,z; char a[50],b[50]; scanf("%d",&x); for(i=1;i<=x;i++) { scanf("%s",a); scanf("%s",b); c=strlen(a); d=strlen(b); for(z=1,y=1;y<=(c/2);y++) { a[c+d-z]=a[c-z]; z++; } for(y=1;y<=d;y++) a[c/2+y-1]=b[y-1]; a[c+d]=‘\0‘; printf("%s\n",a); } }
#include<stdio.h> int main() { int a,n; int A,B; scanf("%d",&a); for(int i=1;i<=a;i++) { A=0;B=0; scanf("%d",&n); while(n!=0) { if(n%2==0) //oushu {A++; n=n/2; } else {B++; n=n-1; } } printf("%d\n",B); } return 0; }
Description
假设一堆由1分、2分、5分组成的n个硬币总面值为m分,求一共有多少种可能的组合方式(某种面值的硬币可以数量可以为0)。
Input
输入数据第一行有一个正整数T,表示有T组测试数据;
接下来的T行,每行有两个数n,m,n和m的含义同上。
Output
对于每组测试数据,请输出可能的组合方式数;
每组输出占一行。
Sample Input
2
3 5
4 8
Sample Output
1
2
#include <stdio.h> int main() { int n, m, x, y, cnt, t, tmp, i; scanf("%d", &t); while(t--){ scanf("%d%d", &n, &m); tmp = 5 * n - m; for(i = cnt = 0; i <= n; ++i) for(int j = 0; j <= n; ++j) if(4*i+3*j==tmp && i+j<=n) ++cnt; printf("%d\n", cnt); } return 0; }
#include<cstdio> #include<algorithm> #include<string.h> #include<stdlib.h> #include<math.h> #define FIN freopen("in.txt","r",stdin) #define eps 1e-9 using namespace std; int mp[55][55],cnt,n,m; int to[][2]={0,1,0,-1,1,0,-1,0}; int main(){ int T; // FIN; scanf("%d",&T); while(T--){ scanf("%d%d",&n,&m); int top=0; cnt=0; for(int i=0;i<n;i++) for(int j=0;j<m;j++){ scanf("%d",&mp[i][j]); top=max(top,mp[i][j]); if(mp[i][j]) cnt++; cnt+=mp[i][j]*4; } for(int x=0;x<n;x++){ for(int y=0;y<m;y++){ for(int i=0;i<4;i++){ int xx=x+to[i][0],yy=y+to[i][1]; if(xx<0||yy<0||xx>=n||yy>=m) continue; cnt-=min(mp[x][y],mp[xx][yy]); } } } printf("%d\n",cnt); } return 0; }
时间: 2024-10-10 11:47:16