2070:
#include <cstdio>
using namespace std;
typedef long long LL;
LL a[55];
int main()
{
a[0] = 0;
a[1] = 1;
a[2] = 1;
for(int i=3; i<55; i++)
{
a[i] = a[i-1] + a[i-2];
}
int n;
while(scanf("%d", &n), n != -1)
{
printf("%lld\n", a[n]);
}
return 0;
}
2071:
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
double a[N];
int main()
{
int t;
scanf("%d", &t);
while(t--)
{
int n;
scanf("%d", &n);
for(int i=0; i<n; i++)
{
scanf("%lf", &a[i]);
}
double maxnum = a[0];
for(int i=1; i<n; i++)
{
if(a[i] > maxnum)
maxnum = a[i];
}
printf("%.2lf\n", maxnum);
}
return 0;
}
2072:
#include <bits/stdc++.h>
using namespace std;
string s, s1;
map<string, int> mp;
int main()
{
ios::sync_with_stdio(0);
while(getline(cin , s))
{
if(s == "#")
break;
s1.clear();
mp.clear();
int slen = s.size();
for(int i=0; i < slen; i++)
{
if(s[i] != ' ')
{
s1.push_back(s[i]);
}
else if(s1.size() != 0)
{
// cout << "s1 = " << s1 << endl;
mp[s1] ++;
s1.clear();
}
}
if(s1.size() != 0)
mp[s1] ++;
cout << mp.size() << endl;
}
return 0;
}
2073:
#include <bits/stdc++.h>
using namespace std;
double cal(double x, double y)
{
double i = 0, j = 1;
double res = 0;
int cnt = 0;
while(i <= y-1 && j <= y)
{
if(cnt % 2 == 0)
{
res += sqrt(i*i + j*j);
i++;
cnt ++;
}
else
{
res += sqrt(i*i + j*j);
j++;
cnt ++;
}
}
return res;
}
double ffabs(double num)
{
if(num < 0)
return -num;
return num;
}
int main()
{
int n;
scanf("%d", &n);
while(n--)
{
double x1, y1, x2, y2;
scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
double dis1 = 0;
if(x1 != 0)
{
dis1 += x1 * sqrt(2.0);
y1 += x1;
x1 = 0;
}
double dis2 = 0;
if(x2 != 0)
{
dis2 += x2 * sqrt(2.0);
y2 += x2;
x2 = 0;
}
dis1 += cal(x1, y1);
dis2 += cal(x2, y2);
printf("%.3lf\n", ffabs(dis2 - dis1));
}
return 0;
}
2074:
// 这题不会写,以后再补
2075:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main()
{
int t;
scanf("%d", &t);
while(t--)
{
LL a, b;
scanf("%lld %lld", &a, &b);
if(a%b == 0)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
2076:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
scanf("%d", &t);
while(t--)
{
double h, m, s;
scanf("%lf %lf %lf", &h, &m, &s);
if(h >= 12.0)
h -= 12.0;
double mc = m*6 + s*0.1;
double hc = h*5*6 + (m + s/60.0) / 60.0 * 30.0;
double ans = 0;
if(hc > mc)
ans = hc - mc;
else
ans = mc - hc;
if(ans > 180.0)
printf("%.0lf\n", floor(360.0 - ans));
else
printf("%.0lf\n", floor(ans));
}
return 0;
}
2077:
// 这题不会,以后再补
2078:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
scanf("%d", &t);
while(t--)
{
int n, m;
scanf("%d %d", &n, &m);
int amin = 1000000, a;
for(int i=0; i<n; i++)
{
scanf("%d", &a);
amin = min(amin, a);
}
printf("%d\n", (100-amin) * (100-amin));
}
return 0;
}
2079:
#include <bits/stdc++.h>
using namespace std;
int D[10];
int n, k;
int sum = 0;
// 第一个参数是已选学分总数,第二个参数是第几个学分的课
void dfs(int s, int t)
{
int i, j;
if(s > n) return;
if(s == n) sum ++;
for(int i=t+1; i<10; i++) // 遍历学分数
{
for(int j=1; j <= D[i]; j++) // 遍历每种学分的课程数
{
dfs(s + i*j, i);
}
}
}
int main()
{
int t;
scanf("%d", &t);
while(t--)
{
scanf("%d %d", &n, &k);
int a, b;
for(int i=0; i<k; i++)
{
scanf("%d %d", &a, &b);
D[a] = b;
}
sum = 0;
dfs(0, 0);
printf("%d\n", sum);
}
return 0;
}