2042.
#include<iostream>
#include<string>
using namespace std;
int digui(int x){
if (x == 0)
return 3;
else
return (digui(x-1)-1)*2;
}
int main()
{
int n,m;
while (cin >> n){
while (n--){
cin >> m;
cout << digui(m) << endl;
}
}
}
2044
#include<iostream>
#include<string>
using namespace std;
int main()
{
int n,a,b;
long long int step[51];
step[1] = 1;
step[2] = 2;
for (int i = 3; i < 51; i++)
step[i] = step[i-1] + step[i - 2];
while (cin >> n){
while (n--){
cin >> a>>b;
cout << step[b - a]<<endl;
}
}
return 0;
}
2019.
#include<iostream>
#include<string>
using namespace std;
int main()
{
int n,m,x;
int a[100];
while (cin >> n>>m){
if (n == 0 && m == 0)
return -1;
for (int i = 0; i < n; i++)
{
cin >> x; a[i] = x;
}
for (int j = 0; j < n; j++)
{
if (m >= a[j] && m <= a[j + 1])
{
for (int b = n ; b >= j + 1; b--)
{
a[b ] = a[b-1];
}
a[j + 1] = m;
break;
}
}
for (int i = 0; i < n; i++)
{
cout << a[i] << " ";
}
cout << a[n] << endl;
}
return 0;
}
2020.
#include<iostream>
#include<string>
using namespace std;
int main()
{
int n,x,temp;
int a[100];
while (cin >> n)
{
if (n == 0)
return -1;
for (int i = 0; i < n; i++)
{
cin >> x;
a[i] = x;
}
for (int i = 0; i < n - 1; i++)
for (int j = n - 1; j > i; j--)
{
if (abs(a[j])>abs(a[j - 1]))
{
temp = a[j];
a[j] = a[j - 1];
a[j - 1] = temp;
}
}
for (int i = 0; i < n-1; i++){
cout << a[i] << " ";
}
cout << a[n - 1] << endl;
}
}
2021.
#include<iostream>
#include<string>
using namespace std;
int main()
{
int n, sum=0;
int a[100];
while (cin >> n)
{
if (n == 0)
return -1;
for (int i = 0; i < n; i++){
cin >> a[i];
sum += a[i]/100;
a[i] = a[i] % 100;
sum += a[i] / 50;
a[i] = a[i] % 50;
sum += a[i] / 10;
a[i] = a[i] % 10;
sum += a[i] / 5;
a[i] = a[i] % 5;
sum += a[i] / 2;
a[i] = a[i] % 2;
sum += a[i] / 1;
}
cout << sum << endl;
sum = 0;
}
}
2022.
#include<iostream>
#include<string>
using namespace std;
int main()
{
int n, m,x;
int max,Ix=0,Iy=0;
while (cin >> m>>n)
{
max = 0;
Ix = 0, Iy = 0;
for (int i =0; i <m; i++)
for (int j = 0; j <n; j++)
{
cin >> x;
if (abs(x)>abs(max))
{
max = x;
Ix = i + 1;
Iy = j + 1;
}
}
cout << Ix << " " << Iy << " " << max << endl;
}
}