C++/*
//网址:https://hm-jnoj.huanma.zone/site/index
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<deque>
#include<cmath>
#include<algorithm>
using namespace std;
#define fst ios::sync_with_stdio(false);
#define fast cin.tie(),cout.tie();
#define ll long long
#define endl '\n'
int main(){
return 0;
}
*/
//01
/*
//1127
#include<bits/stdc++.h>
using namespace std;
int main(){
cout << "*****" << endl;
cout << " ***" << endl;
cout << " *" << endl;
cout << " ***" << endl;
cout << "*****" << endl;
return 0;
}
//1520
#include<bits/stdc++.h>
using namespace std;
int main(){
cout << "1*1=1" << endl;
cout << "2*1=2 2*2=4" << endl;
cout << "3*1=3 3*2=6 3*3=9" << endl;
cout << "4*1=4 4*2=8 4*3=12 4*4=16";
return 0;
}
//1518
#include<bits/stdc++.h>
using namespace std;
int main(){
cout << (2022 + 222) / (17 * 12) + 789;
return 0;
}
*/
//02
/*
//1456
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d,e;
cin >> a >> b >> c >> d >> e;
cout << a + b + c + d + e;
return 0;
}
//1411
#include<bits/stdc++.h>
using namespace std;
int main(){
int a;
cin >> a;
cin >> a;
cout << a;
return 0;
}
//1206
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin >> a >> b;
cout << a * b;
return 0;
}
//1207
#include<bits/stdc++.h>
using namespace std;
int main(){
int tou,jiao;
cin >> tou >> jiao;
for(int t = 0;t <= tou;t++){
for(int j = 0;j <= tou;j++){
if(j * 2 + t * 4 == jiao && j + t == tou){
cout << t << " " << j;
return 0;
}
}
}
//return 0;
}
*/
//04(03意外丢失了awa)
/*
//1786
#include<bits/stdc++.h>
using namespace std;
int main(){
int a;
cin >> a;
cout << a / 10000 % 10;
return 0;
}
//1054
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,g,s,b,q,w,sw;
cin >> n;
g = n % 10;
n /= 10;
s = n % 10;
n /= 10;
b = n % 10;
n /= 10;
q = n % 10;
n /= 10;
w = n % 10;
n /= 10;
sw = n % 10;
cout << g << s << b << q << w << sw;
return 0;
}
//1540
#include<bits/stdc++.h>
using namespace std;
int main(){
double a,b,c,d,e,x,y,time,s;
cin >> a >> b >> c >> d >> e;
x = (a / b + c / d) / 2;
y = (a / b - c / d) / 2;
time = e/(x+y);
s = e - time * y;
cout<<int(s);
return 0;
}
//1540__回滚1__等待回滚2
#include<bits/stdc++.h>
using namespace std;
int main(){
double a,b,c,d,e,x,y,t;
cin >> a >> b >> c >> d >> e;
x = (a / b + c / d) / 2;
y = (a / b - c / d) / 2;
t = e / (x + y);
cout << int(e - t * y);
return 0;
}
//1799
#include<bits/stdc++.h>
using namespace std;
int main(){
double a,b;
int c;
cin >> a >> b;
c = a / b;
cout << a - b * c;
return 0;
}
*/
//05
/*
//1013
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,cnt = 0;
cin >> n;
while(n){
n /= 10;
cnt += 1;
}
if(cnt == 2) cout << 1;
else cout << 0;
return 0;
}
//1016
#include<bits/stdc++.h>
using namespace std;
int main(){
int c,m;
cin >> c >> m;
if(c >= 60 && m < 60 || c < 60 && m >= 60) cout << 1;
else cout << 0;
return 0;
}
//1141
#include<bits/stdc++.h>
using namespace std;
int main(){
//里程标!!!200行
int a,b;
cin >> a >> b;
if(a % 2 == 0 && b % 2 == 0){
cout << "even";
}else if(a % 2 == 1 && b % 2 == 1){
cout << "odd";
}else{
cout << "good luck";
}
return 0;
}
*/
//06
/*
//1391
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
if(n % 2 == 0 && n > 50) cout << "yes";
else cout << "no";
return 0;
}
//1422
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,r = 0;
cin >> n;
if(n > 5000) r = n - 2000;
else if(n > 3000) r = n - 1500;
else if(n > 1000) r = n - 500;
else r = n;
cout << r;
return 0;
}
//1347
#include<bits/stdc++.h>
using namespace std;
int main(){
int y,m,r = 0;
cin >> y >> m;
if(y % 400 == 0 || y % 100 != 0 && y % 4 == 0) r = 1;
if(m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) cout << 31;
else if(m == 2) r == 1?cout << 29:cout << 28;
else cout << 30;
return 0;
}
//1210
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
if(n >= 85) cout << "A";
else if(n >= 70) cout << "B";
else if(n >= 60) cout << "C";
else cout << "D";
return 0;
}
//1542
#include<bits/stdc++.h>
using namespace std;
int main(){
long double w,s,ans;
cin >> w >> s;
if(s < 100) ans = w * s;
else if(s < 200) ans = w * s * 0.98;
else if(s < 500) ans = w * s * 0.95;
else if(s < 1000) ans = w * s * 0.92;
else ans = w * s * 0.9;
cout << ans;
return 0;
}
//1212
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d,ans1,ans2;
cin >> a >> b >> c >> d;
ans1 = a * b;
ans2 = c * d;
if(ans1 == ans2) cout << 0;
else if(ans1 > ans2) cout << 1;
else cout << 2;
return 0;
}
//1543
#include<bits/stdc++.h>
using namespace std;
int main(){
double s_walk = 0,s_bike = 0,n;
cin >> n;
s_walk = n / 1.2;
s_bike = n / 3.0 + 27 + 23;
if(s_walk < s_bike) cout << "Walk";
else if(s_walk > s_bike) cout << "Bike";
else cout << "All";
return 0;
}
//1140
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,t = 0;
cin >> a >> b >> c;
if(a > c){
t = a;
a = c;
c = t;
}if(b > c){
t = b;
b = c;
c = t;
}if(a > b){
t = a;
a = b;
b = t;
}
if(a + b < c) cout << "illegal triangle";
else if(a * a + b * b > c * c) cout << "acute triangle";
else if(a * a + b * b == c * c) cout << "right triangle";
else cout << "obtuse triangle";
return 0;
}
//1384
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m;
cin >> n >> m;
if(n == 1){
if(m == 0 || m == 5) cout <<"YES";
else cout << "NO";
}else if(n == 2){
if(m == 1 || m == 6) cout <<"YES";
else cout << "NO";
}else if(n == 3){
if(m == 2 || m == 7) cout <<"YES";
else cout << "NO";
}else if(n == 4){
if(m == 3 || m == 8) cout <<"YES";
else cout << "NO";
}else if(n == 5){
if(m == 4 || m == 9) cout <<"YES";
else cout << "NO";
}
else if(n == 6) cout << "YES";
else cout << "NO";
return 0;
}
*/
//测验1
/*
//1558
#include<bits/stdc++.h>
using namespace std;
int main(){
cout << " *" << endl;
cout << " ***" << endl;
cout << "*****" << endl;
cout << " ***" << endl;
cout << " *" << endl;
return 0;
}
//1563
#include<bits/stdc++.h>
using namespace std;
int main(){
cout << (18 - 3) / 3;
return 0;
}
//1559
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m,n3 = 0,m3 = 0;
cin >> n >> m;
n3 = n3 * 10 + n % 10;
n /= 10;
//里程标!!!400行
n3 = n3 * 10 + n % 10;
n /= 10;
n3 = n3 * 10 + n % 10;
n /= 10;
//cout << n3;
m3 = m3 * 10 + m % 10;
m /= 10;
m3 = m3 * 10 + m % 10;
m /= 10;
m3 = m3 * 10 + m % 10;
m /= 10;
if(n3 == m3) cout << "Yes";
else cout << "No";
return 0;
}
//2685
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
if(n % 3 == 0 && n % 5 == 0 && n % 7 == 0) cout << "3 5 7";
else if(n % 3 == 0 && n % 5 == 0 && n % 7 != 0) cout << "3 5";
else if(n % 3 == 0 && n % 5 != 0 && n % 7 == 0) cout << "3 7";
else if(n % 3 != 0 && n % 5 == 0 && n % 7 == 0) cout << "5 7";
else if(n % 3 == 0 && n % 5 != 0 && n % 7 != 0) cout << "3";
else if(n % 3 != 0 && n % 5 == 0 && n % 7 != 0) cout << "5";
else if(n % 3 != 0 && n % 5 != 0 && n % 7 == 0) cout << "7";
else cout << "n";
return 0;
}
//1560
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,t = 0;
cin >> a >> b >> c;
if(a > c){
t = a;
a = c;
c = t;
}if(b > c){
t = b;
b = c;
c = t;
}if(a > b){
t = a;
a = b;
b = t;
}
cout << a << " " << b << " " << c;
return 0;
}
*/
//08
/*
//1548
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,ans = 0;
cin >> n;
for(int i = 1;i <= n;i++){
if(i % 2 == 0) ans -= i;
else ans += i;
}
cout << ans;
return 0;
}
//1062
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,ans = 0;
cin >> n;
while(n){
ans += n % 10;
n /= 10;
}
cout << ans;
return 0;
}
//2162
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,c,max = -1e4,min = 1e4;
cin >> n;
for(int i = 1;i <= n;i++){
cin >> c;
if(c > max) max = c;
if(c < min) min = c;
}
cout << max << " " << min;
return 0;
}
//1214
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m = 0,x = 1;
cin >> n;
for(int i = 1;i <= n;i++){
m += x;
x *= 2;
}
cout << m;
return 0;
}
//1552
#include<bits/stdc++.h>
using namespace std;
int main(){
long long n,m,ans;
cin >> n >> m;
ans = pow(n,m);
cout << ans;
return 0;
}
//1800
#include<bits/stdc++.h>
using namespace std;
int main(){
double c,ans = 0,max = 0,min = 100;
for(int i = 1;i <= 10;i++){
cin >> c;
ans += c;
if(c > max) max = c;
if(c < min) min = c;
}
//cout << max << " " << min << endl;
ans = ans - max - min;
cout << ans / 8.0;
return 0;
}
//1554
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
while(n){
cout << n % 10;
n /= 10;
}
return 0;
}
*/
//09
/*
//1735
#include<bits/stdc++.h>
using namespace std;
int main(){
int ans = 0;
for(int i = 0;i <= 1000;i++){
if(i % 3 == 0 || i % 5 == 0 || i % 7 == 0) ans += i;
}
cout << ans;
return 0;
}
//1570
#include<bits/stdc++.h>
using namespace std;
int main(){
int ans = 0;
for(int i = 0;i <= 1000;i++){
if(i % 4 == 0 && i % 5 == 0) ans += i;
}
cout << ans;
return 0;
}
//1213
#include<bits/stdc++.h>
using namespace std;
int main(){
int ans = 0,c;
for(int i = 1;i <= 20;i++){
cin >> c;
if(c < 60) ans++;
}
//里程标!!!600行
cout << ans;
return 0;
}
//1082
#include<bits/stdc++.h>
using namespace std;
int main(){
int k;
cin >> k;
k %= 7;
if((k + 4) > 7) cout << k + 4 - 7;
else cout << k + 4;
return 0;
}
//1068
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
double ans = 0;
cin >> n;
for(int i = 1;i <= n;i++){
if(i % 2) ans -= 1.0 / i;
else ans += 1.0 / i;
}
cout << -ans;
return 0;
}
//1068__回滚1__想了一会儿__等待回滚2
//易错点:想不到整数除以整数结果是整数,会把1.0写成1
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
double ans = 0;
cin >> n;
for(int i = 1;i <= n;i++){
if(i % 2) ans += 1.0 / i;
else ans -= 1.0 / i;
}
cout << ans;
return 0;
}
//1067
#include<bits/stdc++.h>
using namespace std;
int main(){
double ans = 0,k;
int n = 1;
cin >> k;
while(ans <= k){
ans += 1.0 / n;
//cout << ans << endl;
n++;
}
cout << n - 1 << endl;
return 0;
}
//1067__回滚1__想了一会__等待回滚2
//易错点:c和sum的变换
#include<bits/stdc++.h>
using namespace std;
int main(){
int n = 1,k;
double c;
double sum = 0;
cin >> k;
while(k >= sum){
c = 1.0 / n;
//cout << c << "我是c" << endl;
sum += c;
n += 1;
//cout << sum << "我是sum" << endl;
}
cout << n - 1;
return 0;
}
//1063
#include<bits/stdc++.h>
using namespace std;
int main(){
long long n;
cin >> n;
cout << n << " ";
while(n != 1){
if(n % 2 == 0) n /= 2;
else n = n * 3 + 1;
cout << n << " ";
}
return 0;
}
//1572
#include<bits/stdc++.h>
using namespace std;
int main(){
int c,ansadd = 0,anseven = 0;
for(int i = 1;i <= 10;i++){
cin >> c;
if(c % 2 == 0) anseven += c;
else ansadd += c;
}
cout << ansadd << " " << anseven;
return 0;
}
//1571
#include<bits/stdc++.h>
using namespace std;
int main(){
int ans = 0,n;
for(int i = 1;i <= 1000;i++){
n = i;
while(n){
if(n % 10 == 5){
ans += 1;
break;
}
n /= 10;
}
}
cout << ans;
return 0;
}
//1065
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,n,ans = 0,ay;
cin >> ay >> n;
a = ay;
for(int i = 1;i <= n;i++){
ans += a;
a = a * 10 + ay;
//cout <<"我是测试数据"<< a <<"测试完毕"<< endl;
}
cout << ans;
return 0;
}
//1090
#include<bits/stdc++.h>
using namespace std;
int main(){
int x,n,len = 0;
cin >> x >> n;
for(int i = 1;i <= n;i++){
if(x != 6 && x != 7){
len += 250;
}
x += 1;
if(x > 7) x -= 7;
}
cout << len;
return 0;
}
//1090_回滚1_等待回滚2
//易错点:“&&”和“||”要分清
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,x,len = 0;
cin >> x >> n;
for(int i = 1;i <= n;i++){
if(x != 6 && x != 7) len += 250;
x += 1;
if(x > 7) x = 1;
}
cout << len;
return 0;
}
*/
//10
/*
//1475
#include<bits/stdc++.h>
using namespace std;
int main(){
int m,n,f = 1;
cin >> m >> n;
for(int i = m;i <= n;i++){
if(i % 23 == 0){
cout << i;
f = 0;
break;
}
}
if(f) cout << "no";
return 0;
//里程标!!!800行
}
//2086
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,f = 1;
cin >> n;
if(n == 1){
cout << "no";
return 0;
}
for(int i = 2;i < n;i++){
if(n % i == 0){
f = 0;
break;
}
}
if(f) cout << "yes";
else cout << "no";
return 0;
}
//1591
#include<bits/stdc++.h>
using namespace std;
int main(){
int mlen = 0,len = 0,c,x = 0,n;
cin >> n;
cin >> c;
x = c;
for(int i = 2;i <= n;i++){
cin >> c;
if((c - x) == 1) len += 1;
else len = 0;
x = c;
mlen = max(len,mlen);
}
cout << mlen + 1;
return 0;
}
//1592
#include<bits/stdc++.h>
using namespace std;
int main(){
for(int i = 1;i <= 1000;i++){
if(i % 7 == 0 || i % 10 == 7) cout << i << " ";
}
return 0;
//里程标!!!800行
}
//1092
#include<bits/stdc++.h>
using namespace std;
int main(){
int n = 1,ans = 0;
while(ans <= 500){
ans += n;
n += 1;
}
cout << n - 1;
return 0;
}
//1226
#include<bits/stdc++.h>
using namespace std;
int main(){
int x = 0,c,n,f = 1;
cin >> n;
cin >> c;
for(int i = 1;i <= n - 1;i++){
x = c;
cin >> c;
if((x + 1) != c){
cout << i + 1;
f = 0;
break;
}
}
if(f) cout << 1;
return 0;
}
//1226__回滚1__等待回滚2
//易错点:在for循环里容易忘写x = c
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,c,x,f = 1;
cin >> n;
cin >> c;
x = c;
for(int i = 1;i <= n - 1;i++){
cin >> c;
if((x + 1) != c){
cout << i + 1;
f = 0;
break;
}
x = c;
}
if(f) cout << 1;
return 0;
}
*/
//11
/*
//1593
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m;
cin >> n >> m;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++){
cout << "*";
}
cout << endl;
}
return 0;
}
//1338
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m;
cin >> n >> m;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++){
if(i == 1 || i == n || j == m || j == 1) cout << "#";
else cout << "*";
}
cout << endl;
}
return 0;
}
//1228__微难点__但做出来了
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= n - i;j++) cout << " ";
for(int j = 1;j <= 2 * i - 1;j++) cout << "*";
cout << endl;
}
return 0;
}
//1228__回滚1__等待回滚2
//易错点:变量i和空格、“*”号的关系混淆
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= n - i;j++) cout << " ";
for(int j = 1;j <= i * 2 - 1;j++) cout << "*";
cout << endl;
}
return 0;
}
//1097
#include<bits/stdc++.h>
using namespace std;
int main(){
for(int i = 1;i <= 9;i++){
for(int j = 1;j <= 9;j++){
cout << i << "*" << j << "=" << i * j << endl;
}
}
return 0;
}
//1106
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,x,c,cnt = 0;
cin >> n >> x;
for(int i = 1;i <= n;i++){
c = i;
while(c){
if(c % 10 == x) cnt += 1;
c /= 10;
}
//里程标!!!1000行
}
cout << cnt;
return 0;
}
//1106
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,x,c,cnt = 0;
cin >> n >> x;
for(int i = 1;i <= n;i++){
c = i;
while(c){
if(c % 10 == x) cnt += 1;
c /= 10;
}
}
cout << cnt;
return 0;
}
//1476
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,cnt = 1,sum = 0,c;
cin >> n;
for(int i = 1;i <= n;i++){
if(i % 7 == 0) continue;
c = i;
sum = 0;
while(c){
sum += c % 10;
c /= 10;
}
//cout << i << "的总和:" << sum << endl;
if(sum != 7) cnt += i;
}
cout << cnt - 1;
return 0;
}
//1476__回滚1__等待回滚2
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,sum = 0;
cin >> n;
for(int i = 1;i <= n;i++){
if(i % 7 == 0) continue;
int cnt = 0,c = i;
while(c){
cnt += c % 10;
c /= 10;
}
if(cnt == 7) continue;
sum += i;
//cout << i << endl;
}
cout << sum;
return 0;
}
//1594
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= i;j++){
cout << i;
}
cout << endl;
}
return 0;
}
//1595
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k = 1;
cin >> n;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= 5;j++){
cout << j * k << " ";
}
k += 1;
cout << endl;
}
return 0;
}
//1101
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m,f = 1,s;
cin >> n >> m;
for(int i = n;i <= m;i++){
s = 0;
//cout << "到" << i << "了" << endl;
for(int j = 1;j <= i - 1;j++){
if(i % j == 0){
s += j;
//cout << "+=了" << j << endl;
}
}
if(i == s){
cout << i << " ";
f = 0;
}
}
if(f) cout << "no answer";
return 0;
}
*/
//12
/*
//1227
#include<bits/stdc++.h>
using namespace std;
int main(){
int x,y,f = 1;
cin >> x >> y;
for(int i = x;i <= y;i++){
if(i % 7 == 0 || i % 8 == 0){
cout << i << " ";
f = 0;
}
}
if(f) cout << "no answer";
return 0;
}
//1374
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,cnt = 0;
cin >> n;
for(int i = 1;i <= n;i++){
if(n % i == 0) cnt += 1;
}
cout << cnt;
return 0;
}
//1102
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,f = 1;
cin >> n;
for(int i = 1;i <= n;i++){//可以把“i <= n”改成“i * i <= n”,减少时间复杂度。
for(int j = 1;j <= n;j++){//可以把“j <= n”改成“j * j <= n”,减少时间复杂度。
if(i * i + j * j == n){
cout << i << " " << j << endl;
f = 0;
}
}
}
if(f) cout << "no answer";
return 0;
}
//1585
#include<bits/stdc++.h>
using namespace std;
int main(){
for(int i = 0;i <= 100 / 5;i++){ //从0开始
for(int j = 0;j <= 100 / 3;j++){
for(int k = 0;k <= 100 * 3;k += 3){ //“k += 3”是重点
if(i * 5 + j * 3 + k / 3 == 100 && i + j + k == 100){
cout << i << " " << j << " " << k << endl;
}
}
}
}
return 0;
}
//1585__回滚1__等待回滚2
#include<bits/stdc++.h>
using namespace std;
int main(){
for(int i = 0;i <= 100 / 5;i++){
for(int j = 0;j <= 100 / 3;j++){
for(int k = 0;k <= 100 * 3;k += 3){
if(i * 5 + j * 3 + k / 3 == 100 && i + j + k == 100){
cout << i << " " << j << " " << k << endl;
}
}
}
}
return 0;
}
//1078
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d;
for(int i = 1;i <= 100;i++){
int x = i * i;
d = x % 10;
x /= 10;
c = x % 10;
x /= 10;
b = x % 10;
x /= 10;
a = x % 10;
x /= 10;
if(d == c && a == b && a != c && x == 0) cout << i * i << " ";
}
return 0;
}
//1241
#include<bits/stdc++.h>
using namespace std;
int main(){
int x,y,cnt = 0,f = 1;
cin >> x >> y;
for(int i = x;i <= y;i++){
if(i % 100 != 0 && i % 4 == 0 || i % 400 == 0){
cnt += 1;
f = 0;
}
}
if(f){
cout << 0;
return 0;
}
cout << cnt << endl;
for(int i = x;i <= y;i++){
if(i % 100 != 0 && i % 4 == 0 || i % 400 == 0){
cout << i << " ";
}
}
return 0;
}
//1360
#include<bits/stdc++.h>
using namespace std;
bool ip(int n){
int f = 1;
for(int i = 2;i < n;i++){
if(n % i == 0) f = 0;
}
if(f) return true;
return false;
}
int main(){
int n,m,cnt = 0;
cin >> n >> m;
for(int i = n;i <= m;i++){
if(ip(i) && i != 1) cnt += i;
}
cout << cnt;
return 0;
}
//1086
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
for(int i = 100;i <= 999;i++){
int x = i;
a = x % 10;
x /= 10;
b = x % 10;
x /= 10;
c = x % 10;
if(a * a * a + b * b * b + c * c * c == i) cout << i << " ";
}
return 0;
}
*/
//13
/*
//1583
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= n - i;j++){
cout << " ";
}
for(int j = 1;j <= i;j++){
cout << "*";
}
cout << endl;
}
return 0;
}
//1173
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,x,sum = 0,mx;
double mx_d;
cin >> n;
cin >> x;
mx = x;
sum += x;
for(int i = 1;i < n;i++){
cin >> x;
if(x > mx) mx = x;
sum += x;
}
sum -= mx;
mx_d = mx;
mx_d /= 2.0;
sum += ceil(mx_d);
cout << sum;
return 0;
}
//1586
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,f = 1;
cin >> n;
for(int i = 1;i <= 3;i++){
for(int j = 1;j <= 3;j++){
for(int k = 1;k <= 3;k++){
for(int m = 1;m <= 3;m++){
if(i + j + k + m == n){
cout << i << " " << j << " " << k << " " << m << endl;
f = 0;
}
}
}
}
}
if(f) cout << 0;
return 0;
}
//1359
#include<bits/stdc++.h>
using namespace std;
int main(){
long long n,sum = 1,ws = 0,s_b;
cin >> n;
for(int i = 1;i <= n;i++){
sum *= i;
}
cout << sum << " ";
s_b = sum;
while(s_b){
s_b /= 10;
ws += 1;
}
cout << ws;
return 0;
}
//1348
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m,f = 1;
cin >> n >> m;
for(int i = 2;i <= min(n,m);i++){
if(n % i == 0 && m % i == 0) f = 0;
}
if(f) cout << "yes";
else cout << "no";
return 0;
}
//1240
#include<bits/stdc++.h>
using namespace std;
int main(){
int a1,a2,n,d;
cin >> a1 >> a2 >> n;
d = a2 - a1;
for(int i = 0;i <= n - 1;i++){
cout << a1 + d * i << " ";
}
return 0;
}
//2531
#include<bits/stdc++.h>
using namespace std;
long long a[50];
int main(){
int n;
cin >> n;
a[1] = 1;
a[2] = 1;
for(int i = 3;i <= 46;i++){
a[i] = a[i - 1] + a[i - 2];
}
cout << a[n];
return 0;
}
//1238
#include<bits/stdc++.h>
using namespace std;
int main(){
int all,mn = 1000,x;
for(int i = 1;i <= 23;i++){
cin >> x;
if(x < mn) mn = x;
all += x;
}
cout << all * mn;
return 0;
}
//1237
#include<bits/stdc++.h>
using namespace std;
int a[105];
int main(){
int n,mn = 9999,cnt = 0,x;
cin >> n;
for(int i = 1;i <= n;i++){
cin >> x;
a[i] = x;
if(x < mn) mn = x;
}
for(int i = 1;i <= n;i++){
if(a[i] == mn) cnt++;
}
cout << cnt;
return 0;
}
//1474__微难点
#include<bits/stdc++.h>
using namespace std;
long long f_x(int n){
long long cnt = 1;
for(int i = 1;i <= n;i++){
cnt *= i;
}
return cnt;
}
int main(){
long long n,sum = 0;
cin >> n;
for(int i = 1;i <= n;i++){
sum += f_x(i);
}
cout << sum;
return 0;
}
//1394
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,n1 = 0,n2 = 0,n3 = 0,x;
cin >> n;
for(int i = 1;i <= n;i++){
cin >> x;
if(x < 100) n1++;
else if(x < 150) n2++;
else n3++;
}
cout << n1 << " " << n2 << " " << n3;
return 0;
}
//1608
#include<bits/stdc++.h>
using namespace std;
int main(){
for(int i = 1;i <= 9;i++){
for(int j = 1;j <= 9;j++){
for(int k = 1;k <= 9;k++){
if(i * 101 + j * 20 + k * 101 == 1333){
cout << i * 100 + j * 10 + k << endl;
}
}
}
}
return 0;
}
//1609
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d,e,f,g,h,i;
cin >> a >> b >> c >> d >> e >> f >> g >> h >> i;
cout << a + c + e + g + i;
return 0;
}
//1610
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,f = 1;
cin >> n;
for(int d = 0;d <= n / 5;d++){
for(int m = 0;m <= n / 3;m++){
for(int x = 0;x <= n * 3;x += 3){
if(d * 5 + m * 3 + x / 3 == n && d + m + x == n){
cout << d << " " << m << " " << x << endl;
f = 0;
}
}
}
}
if(f) cout << "No Answer.";
return 0;
}
//1396
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,x,y,rest;
cin >> n >> x >> y;
int mn = 100000;
for(int i = 0;i <= n / x;i++){
rest = n - x * i;
int j = rest / y;
rest = rest - y * j;
if(rest < mn) mn = rest;
}
cout << mn;
return 0;
}
//1396__回滚1__等待回滚2
#include<bits/stdc++.h>
using namespace std;
int main(){
int x,y,n,rest,mn = 100000;
cin >> n >> x >> y;
for(int i = 0;i <= n / x;i++){
rest = n - i * x;
int j = rest / y;
rest = rest - j * y;
mn = min(mn,rest);
}
cout << mn;
return 0;
}
*/
//15
/*
//1479
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int a[N],n;
int main(){
cin >> n;
for(int i = 1;i <= n;i++) cin >> a[i];
for(int i = 1;i <= n;i++) cout << a[i] << " ";
return 0;
}
//1020
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int a[N],n;
int main(){
cin >> n;
for(int i = 1;i <= n;i++) cin >> a[i];
for(int i = n;i >= 1;i--) cout << a[i] << " ";
return 0;
}
//1236
#include<bits/stdc++.h>
using namespace std;
long long a[105],n,l,r,cnt;
int main(){
cin >> n;
for(int i = 1;i <= n;i++) cin >> a[i];
cin >> l >> r;
for(int i = l;i <= r;i++) cnt += a[i];
cout << cnt;
return 0;
}
//1017
#include<bits/stdc++.h>
using namespace std;
int a[85],n,x,p_cnt;
double s_cnt;
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> x;
a[i] = x;
s_cnt += x;
}
s_cnt /= n;
for(int i = 1;i <= n;i++){
if(a[i] < s_cnt) p_cnt += 1;
}
cout << p_cnt;
return 0;
}
//2531
#include<bits/stdc++.h>
using namespace std;
long long a[50],n;
int main(){
a[1] = 1;
a[2] = 1;
cin >> n;
for(int i = 3;i <= 46;i++){
a[i] = a[i - 1] + a[i - 2];
}
cout << a[n];
return 0;
}
//1605
#include<bits/stdc++.h>
using namespace std;
int y,m,d,d_sum,a[15] = {0,31,0,31,30,31,30,31,31,30,31,30,31};
int main(){
cin >> y >> m >> d;
if(y % 100 != 0 && y % 4 == 0 || y % 400 == 0) a[2] = 29;
else a[2] = 28;
for(int i = 1;i <= m - 1;i++){
d_sum += a[i];
}
cout << d_sum + d;
return 0;
}
//1605__回滚1__等待回滚2
#include<bits/stdc++.h>
using namespace std;
int a[15] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int main(){
int y,m,d,day = 0;
cin >> y >> m >> d;
if(y % 100 != 0 && y % 4 == 0 || y % 400 == 0) a[2] = 29;
for(int i = 1;i <= m - 1;i++){
day += a[i];
}
cout << day + d;
return 0;
}
//1350
#include<bits/stdc++.h>
using namespace std;
int a[105],n,c;
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> c;
if(c == 62) c = 26;
a[i] = c;
cout << a[i] << " ";
}
return 0;
}
//1262
#include<bits/stdc++.h>
using namespace std;
int a[105],n,cnt;
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> a[i];
}
for(int i = 2;i < n;i++){
if(a[i] > a[i - 1] && a[i] > a[i + 1]){
cnt++;
}
}
cout << cnt;
return 0;
}
//1606
#include<bits/stdc++.h>
using namespace std;
int a[10005],n,k,c,m,x,y;
int main(){
cin >> n >> m >> k;
for(int i = 1;i <= n + 5;i++){
a[i] = i;
}
for(int i = 1;i <= m;i++){
cin >> x >> y;
c = a[x];
a[x] = a[y];
a[y] = c;
}
cout << a[k];
return 0;
}
*/
//16
/*
//1191
#include<bits/stdc++.h>
using namespace std;
int a[55],n,k;
int main(){
cin >> n >> k;
for(int i = 1;i <= n;i++){
cin >> a[i];
}
a[n + 1] = k;
sort(a + 1,a + n + 2);
for(int i = 1;i <= n + 1;i++){
cout << a[i] << " ";
}
return 0;
}
//1603
#include<bits/stdc++.h>
using namespace std;
int n,a[105],mn = 214748637,p;
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> a[i];
if(a[i] < mn) mn = a[i];
}
for(int i = 1;i <= n;i++){
if(a[i] == mn) p = i;
}
for(int i = p;i <= n;i++){
a[i] = a[i + 1];
}
for(int i = 1;i < n;i++){
cout << a[i] << " ";
}
return 0;
}
//1604
#include<bits/stdc++.h>
using namespace std;
int n,m,a[1005],u,v,cnt;
int main(){
cin >> n >> m;
for(int i = 0;i <= n;i++){
a[i] = 1;
}
for(int i = 1;i <= m;i++){
cin >> u >> v;
for(int i = u;i <= v;i++){
a[i] = 0;
}
}
for(int i = 0;i <= n;i++){
if(a[i] == 1) cnt++;
}
cout << cnt;
return 0;
}
//1607
#include<bits/stdc++.h>
using namespace std;
int n,a[10005],j = 1;
int main(){
cin >> n;
while(n != 1){
a[j] = n;
j += 1;
if(n % 2) n = n * 3 + 1;
else n /= 2;
}
cout << 1 << " ";
for(int i = j - 1;i > 0;i--) cout << a[i] << " ";
return 0;
}
//1229
#include<bits/stdc++.h>
using namespace std;
int n,k,a[105];
int main(){
cin >> n >> k;
for(int i = 1;i <= n;i++){
cin >> a[i];
}
for(int i = k;i <= n + k - 1;i++){
if(i <= n) cout << a[i] << " ";
else cout << a[i - n] << " ";
}
return 0;
}
//1229__回滚1__等待回滚2
#include<bits/stdc++.h>
using namespace std;
int a[105],n,k;
int main(){
cin >> n >> k;
for(int i = 1;i <= n;i++) cin >> a[i];
for(int i = k;i <= n + k - 1;i++){
if(i <= n) cout << a[i] << " ";
else cout << a[i - n] << " ";
}
return 0;
}
//1366
#include<bits/stdc++.h>
using namespace std;
int n,a[105],cnt;
int main(){
cin >> n;
for(int i = 1;i <= n;i++) cin >> a[i];
for(int i = 1;i <= n;i++){
for(int j = i;j <= n;j++){
if(a[i] > a[j]) cnt++;
}
}
cout << cnt;
return 0;
}
//1383
#include<bits/stdc++.h>
using namespace std;
int n,p;
double a[105],c,mx = 0;
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> c;
a[i] = c;
if(mx < c) mx = c;
}
for(int i = 1;i <= n;i++){
if(a[i] == mx){
p = i;
break;
}
}
if(p % 2) cout << "feizhai";
else cout << "feicheng";
return 0;
}
//1230
#include<bits/stdc++.h>
using namespace std;
int n,a[105],cnt;
int main(){
cin >> n;
for(int i = 1;i <= n;i++) cin >> a[i];
for(int i = 1;i <= n;i++){
cnt = 0;
for(int j = 1;j <= i;j++){
if(a[j] < a[i]) cnt++;
}
cout << cnt << " ";
}
return 0;
}
//1602
#include<bits/stdc++.h>
using namespace std;
int n,k,m,a[105];
int main(){
cin >> n >> k >> m;
for(int i = 0;i < n;i++) cin >> a[i];
for(int i = k - 1;i < m + k - 1;i++){
cout << a[i % n] << " ";
}
return 0;
}
//1602__回滚1__等待回滚2
#include<bits/stdc++.h>
using namespace std;
int n,k,m,a[105];
int main(){
cin >> n >> k >> m;
for(int i = 0;i < n;i++) cin >> a[i];
for(int i = k - 1;i < k + m - 1;i++){
cout << a[i % n] << " ";
}
return 0;
}
*/
//17
/*
//1037
#include<bits/stdc++.h>
using namespace std;
int n,c,a[15];
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> c;
a[c]++;
}
for(int i = 1;i <= 10;i++){
cout << a[i] << " ";
}
return 0;
}
//1029
#include<bits/stdc++.h>
using namespace std;
int n,a[1005];
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> a[i];
}
sort(a + 1,a + n + 1);
for(int i = 1;i <= n;i++) cout << a[i] << " ";
return 0;
}
//1192
#include<bits/stdc++.h>
using namespace std;
int n,c,a[5005];
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> c;
a[c]++;
if(a[c] == 1) cout << c << " ";
}
return 0;
}
//1040
#include<bits/stdc++.h>
using namespace std;
int n,a[105];
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> a[i];
}
for(int i = 1;i <= n;i++){
int c = a[i],cnt = 1;
for(int j = 1;j <= n;j++){
if(a[j] > c) cnt++;
}
cout << a[i] << " " << cnt << endl;
}
return 0;
}
//1039
#include<bits/stdc++.h>
using namespace std;
int n,a[55],mx = -1e6;
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> a[i];
}
for(int i = 1;i <= n;i++){
for(int j = i;j <= n;j++){
int cnt = 0;
for(int k = i;k <= j;k++){
cnt += a[k];
}
mx = max(mx,cnt);
}
}
cout << mx;
return 0;
}
//1239
#include<bits/stdc++.h>
using namespace std;
int n,m,a[3005],mn = 300000;
int main(){
cin >> n >> m;
for(int i = 1;i <= n;i++) cin >> a[i];
for(int l = 1;l <= n - m + 1;l++){
int r = l + m - 1;
int cnt = 0;
for(int i = l;i <= r;i++){
cnt += a[i];
}
mn = min(mn,cnt);
}
cout << mn;
return 0;
}
//1388
#include<bits/stdc++.h>
using namespace std;
int a[25],n,m,c;
int main(){
cin >> n >> m;
for(int i = 1;i <= n;i++){
cin >> c;
a[c]++;
}
for(int i = 1;i <= m;i++){
cout << a[i] << " ";
}
return 0;
}
//1618
#include<bits/stdc++.h>
using namespace std;
int a[1005],n,c;
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> c;
a[c]++;
}
for(int i = 0;i <= 1000;i++){
if(a[i] == 0) continue;
cout << i << " ";
}
return 0;
}
*/
//18
/*
//1335
#include<bits/stdc++.h>
using namespace std;
long long n,l = 1;
int a[105];
int main(){
cin >> n;
if(n == 0){
cout << 0;
}
while(n){
a[l] = n % 2;
n /= 2;
l++;
}
for(int i = l - 1;i >= 1;i--){
cout << a[i];
}
return 0;
}
//1379
#include<bits/stdc++.h>
using namespace std;
int l,t,u,d,n;
int main(){
cin >> n >> u >> d;
while(1){
l += u;
t += 1;
if(l >= n){
cout << t;
return 0;
}else{
l -= d;
t += 1;
}
}
return 0;
}
//1031
#include<bits/stdc++.h>
using namespace std;
int d[105];
int main(){
for(int i = 1;i <= 100;i++){
for(int j = 1;j <= 100;j++){
if(j % i == 0){
if(d[j]) d[j] = 0;
else d[j] = 1;
}
}
}
for(int i = 1;i <= 100;i++){
if(d[i]) cout << i << " ";
}
return 0;
}
//1353
#include<bits/stdc++.h>
using namespace std;
int c[5],m[5];
int main(){
for(int i = 1;i <= 3;i++) cin >> c[i] >> m[i];
for(int i = 1;i <= 100;i++){
int a = (i % 3 == 0)?3:i % 3;
int b = (a == 3)?1:a + 1;
if(m[b] + m[a] <= c[b]){
m[b] += m[a];
m[a] = 0;
}else{
m[a] -= c[b] - m[b];
m[b] = c[b];
}
}
for(int i = 1;i <= 3;i++) cout << m[i] << " ";
return 0;
}
//1372
#include<bits/stdc++.h>
using namespace std;
int jiu,ping,gai,sum,m,n;
int main(){
cin >> m >> n;
jiu = n / m;
ping = jiu;
gai = jiu;
sum = jiu;
while(jiu){
jiu = ping / 2 + gai / 4;
ping = jiu + ping % 2;
gai = jiu + gai % 4;
sum += jiu;
}
cout << sum;
return 0;
}
//1443
#include<bits/stdc++.h>
using namespace std;
int n,k,a[100005],d = 1;
int main(){
cin >> n >> k;
for(int i = 1;i <= n;i++){
cin >> a[i];
}
while(k >= a[d]){
k -= a[d];
d += 1;
if(d > n) d = 1;
}
cout << d;
return 0;
}
//1134
#include<bits/stdc++.h>
using namespace std;
int sum,n,qi;
int main(){
cin >> n;
while(n >= 3){
qi = n / 3;
n %= 3;
sum += qi;
n += qi;
}
if(n == 2) sum += 1;
cout << sum;
return 0;
}
//1038
#include<bits/stdc++.h>
using namespace std;
int a[15],an;
int main(){
for(int i = 1;i <= 1000;i++){
an += i;
if(an > 10) an %= 10;
a[an] = 1;
}
for(int i = 1;i <= 10;i++){
if(a[i] == 0) cout << i << " ";
}
return 0;
}
//1403
#include<bits/stdc++.h>
using namespace std;
int n,a[100005],fl,t;
int main(){
cin >> n;
for(int i = 1;i <= n;i++) cin >> a[i];
for(int i = 1;i <= n;i++){
if(a[i] > fl) t += (a[i] - fl) * 6;
else if(fl > a[i]) t += (fl - a[i]) * 4;
t += 5;
fl = a[i];
}
cout << t;
return 0;
}
*/
//19
/*
//1620
#include<bits/stdc++.h>
using namespace std;
#define N 105
int a[N][N],n,m;
int main(){
cin >> n >> m;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++){
cin >> a[i][j];
}
}
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++){
cout << a[i][j] << " ";
}
cout << endl;
}
return 0;
}
//1389
#include<bits/stdc++.h>
using namespace std;
#define N 105
int a[N][N],n;
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= n;j++){
cin >> a[i][j];
}
}
int cnt = 0;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= n;j++){
if(i == j || i + j == n + 1) cnt += a[i][j];
}
}
cout << cnt;
return 0;
}
//1041
#include<bits/stdc++.h>
using namespace std;
#define N 105
int a[N][N],n,m;
int main(){
cin >> n >> m;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++){
cin >> a[j][i];
}
}
for(int i = 1;i <= m;i++){
for(int j = 1;j <= n;j++){
cout << a[i][j] << " ";
}
cout << endl;
}
return 0;
}
//1042
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
cin >> n;
switch(n){
case 1:cout << "1"; break;
case 2:cout << "1" << endl << "1 1";break;
case 3:cout << "1" << endl << "1 1" << endl << "1 2 1";break;
case 4:cout << "1" << endl << "1 1" << endl << "1 2 1" << endl << "1 3 3 1";break;
case 5:cout << "1" << endl << "1 1" << endl << "1 2 1" << endl << "1 3 3 1" << endl << "1 4 6 4 1";break;
case 6:cout << "1" << endl << "1 1" << endl << "1 2 1" << endl << "1 3 3 1" << endl << "1 4 6 4 1" << endl << "1 5 10 10 5 1";break;
case 7:cout << "1" << endl << "1 1" << endl << "1 2 1" << endl << "1 3 3 1" << endl << "1 4 6 4 1" << endl << "1 5 10 10 5 1" << endl << "1 6 15 20 15 6 1";break;
case 8:cout << "1" << endl << "1 1" << endl << "1 2 1" << endl << "1 3 3 1" << endl << "1 4 6 4 1" << endl << "1 5 10 10 5 1" << endl << "1 6 15 20 15 6 1" << endl << "1 7 21 35 35 21 7 1";break;
case 9:cout << "1" << endl << "1 1" << endl << "1 2 1" << endl << "1 3 3 1" << endl << "1 4 6 4 1" << endl << "1 5 10 10 5 1" << endl << "1 6 15 20 15 6 1" << endl << "1 7 21 35 35 21 7 1" << endl << "1 8 28 56 70 56 28 8 1";break;
case 10:cout << "1" << endl << "1 1" << endl << "1 2 1" << endl << "1 3 3 1" << endl << "1 4 6 4 1" << endl << "1 5 10 10 5 1" << endl << "1 6 15 20 15 6 1" << endl << "1 7 21 35 35 21 7 1" << endl << "1 8 28 56 70 56 28 8 1" << endl << "1 9 36 84 126 126 84 36 9 1";break;
}
return 0;
}
//1044
#include<bits/stdc++.h>
using namespace std;
int a[15][15],n,m,mx = -10;
int main(){
cin >> n >> m;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++){
cin >> a[i][j];
if(a[i][j] > mx){
mx = a[i][j];
//cout << mx << "最大!!" << endl;
}
}
}
int f = 0;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++){
if(a[i][j] == mx && f == 0){
//cout << "找到了!";
f = 1;
cout << i << " " << j;
break;
}
}
}
return 0;
}
//1621
#include<bits/stdc++.h>
using namespace std;
#define N 205
int a[N][N][N],k,x,y,p,q,x1,z1,y_1,x2,z2,y2;
int main(){
cin >> k >> x >> y;
for(int e = 1;e <= k;e++){
for(int b = 1;b <= x;b++){
for(int c = 1;c <= y;c++){
a[e][b][c] = 1;
}
}
}
cin >> q;
while(q--){
cin >> z1 >> x1 >> y_1 >> z2 >> x2 >> y2;
for(int e = z1;e <= z2;e++){
for(int b = x1;b <= x2;b++){
for(int c = y_1;c <= y2;c++){
a[e][b][c] = 0;
}
}
}
}
int cnt = 0;
for(int e = 1;e <= k;e++){
for(int b = 1;b <= x;b++){
for(int c = 1;c <= y;c++){
if(a[e][b][c] == 1) cnt++;
}
}
}
cout << cnt;
return 0;
}
//1390
#include<bits/stdc++.h>
using namespace std;
#define N 20
int a[N][N],n;
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= n;j++){
if(i + j == n + 1) a[i][j] = 1;
}
}
for(int i = 1;i <= n;i++){
for(int j = 1;j <= n;j++){
cout << a[i][j] << " ";
}
cout << endl;
}
return 0;
}
//1481
#include<bits/stdc++.h>
using namespace std;
int a[15][15],n,m,cnt;
int main(){
cin >> n >> m;
for(int i = 1;i <= n;i++){
int sum = 0;
for(int j = 1;j <= m;j++){
cin >> a[i][j];
if(a[i][j] > sum) sum = a[i][j];
}
cnt += sum;
}
cout << cnt;
return 0;
}
//1622
#include<bits/stdc++.h>
using namespace std;
int a[15][15],n,m,x1,y_1,x2,y2;
int main(){
cin >> n >> m;
while(m--){
cin >> x1 >> y_1 >> x2 >> y2;
for(int i = x1;i <= x2;i++){
for(int j = y_1;j <= y2;j++){
a[i][j] += 1;
}
}
}
for(int i = 1;i <= n;i++){
for(int j = 1;j <= n;j++){
cout << a[i][j] << " ";
}
cout << endl;
}
return 0;
}
*/
//20
/*
//1028
#include<bits/stdc++.h>
using namespace std;
char c;
int main(){
cin >> c;
cout << " " << c << endl << " " << c << c << c << endl << c << c << c << c << c;
return 0;
}
//1055
#include<bits/stdc++.h>
using namespace std;
char c;
int t;
int main(){
cin >> c >> t;
cout << char(c + t);
return 0;
}
//1027
#include<bits/stdc++.h>
using namespace std;
char c;
int main(){
cin >> c;
cout << char(c - 'a' + 'A');
return 0;
}
//1011
#include<bits/stdc++.h>
using namespace std;
char c;
int main(){
cin >> c;
if(c >= 'a' && c <= 'z') cout << "yes";
else cout << "no";
return 0;
}
//1627
#include<bits/stdc++.h>
using namespace std;
char c[15];
int main(){
cin >> c;
if(c[0] >= 'A' && c[0] <= 'Z') c[0] += 'a' - 'A';
else if(c[0] >= '0' && c[0] <= '9') c[0] += 'a' - '0';
if(c[9] >= 'A' && c[9] <= 'Z') c[9] += 'a' - 'A';
else if(c[9] >= '0' && c[9] <= '9') c[9] += 'a' - '0';
cout << c;
return 0;
}
//1628
#include<bits/stdc++.h>
using namespace std;
char c[10];
int n;
int main(){
cin >> n;
while(n--){
cin >> c;
if(c[0] == '8' || c[1] == '8' || c[2] == '8' || c[3] == '8' || c[4] == 'M'){
cout << c;
return 0;
}
}
cout << c;
return 0;
}
//1049
#include<bits/stdc++.h>
using namespace std;
char c;
int main(){
cin >> c;
cout << " " << c << endl;
cout << " " << c << c << c << endl;
cout << "" << c << c << c << c << c << endl;
cout << " " << c << c << c << endl;
cout << " " << c;
return 0;
}
//1483
#include<bits/stdc++.h>
using namespace std;
char c;
int main(){
cin >> c;
cout << int(c);
return 0;
}
//1345
#include<bits/stdc++.h>
using namespace std;
char c[20];
int a;
int main(){
cin >> c;
a = c[16] - '0';
if(a % 2) cout << "M";
else cout << "W";
return 0;
}
*/
//21
/*
//1268
#include<bits/stdc++.h>
using namespace std;
char c[55];
int main(){
cin >> c;
int len = strlen(c);
for(int i = 1;i < len;i++){
if(c[i] >= 'A' && c[i] <= 'Z') c[i] += 'a' - 'A';
}
if(c[0] >= 'a' && c[0] <= 'z') c[0] -= 'a' - 'A';
cout << c;
return 0;
}
//1266
#include<bits/stdc++.h>
using namespace std;
int n;
char c[55];
int main(){
cin >> n >> c;
int len = strlen(c);
for(int i = 0;i < len;i++){
c[i] += n;
if(c[i] < 'a' || c[i] > 'z'){
while(c[i] < 'a' || c[i] > 'z'){
c[i] -= 'z' - 'a' + 1;
}
}
}
cout << c;
return 0;
}
//1112
#include<bits/stdc++.h>
using namespace std;
int n;
char c[85][30],l[85];
int main(){
cin >> n;
for(int i = 0;i < n;i++){
cin >> c[i];
}
cin >> l;
for(int i = 0;i < n;i++){
if(strcmp(c[i],l) == 0){
cout << i + 1;
}
}
return 0;
}
//1624
#include<bits/stdc++.h>
using namespace std;
int j,k;
char c[1005],a[1005],b[1005];
int main(){
cin >> c;
for(int i = 0;i < strlen(c);i++){
if(i % 2){
a[j] = c[i];
j++;
}else{
b[k] = c[i];
k++;
}
}
if(strcmp(a,b) > 0){
strcat(a,b);
cout << a;
}else{
strcat(b,a);
cout << b;
}
return 0;
}
//1253
#include<bits/stdc++.h>
using namespace std;
char c[1005];
int sum;
int main(){
cin >> c;
for(int i = 0;i < strlen(c);i++){
sum += c[i] - '0';
}
if(sum % 3) cout << "no";
else cout << "yes";
return 0;
}
//1235
#include<bits/stdc++.h>
using namespace std;
char c[1005];
int t;
int main(){
cin >> t;
while(t--){
cin >> c;
int f = 1;
for(int i = 0;i < strlen(c);i++){
if(c[i] >= 'a' && c[i] <= 'z' || c[i] >= 'A' && c[i] <= 'Z' || c[i] == '_' || c[i] >= '0' && c[i] <= '9'){
continue;
}else{
f = 0;
}
}
if(c[0] >= '0' && c[0] <= '9') f = 0;
if(f) cout << "yes" << endl;
else cout << "no" << endl;
}
return 0;
}
//1623
#include<bits/stdc++.h>
using namespace std;
int n;
char s1[15],s2[15];
int main(){
cin >> n;
while(n--){
cin >> s1 >> s2;
//R石头;S剪刀;P布
if(s1[0] == 'R' && s2[0] == 'S' || s1[0] == 'S' && s2[0] == 'P' || s1[0] == 'P' && s2[0] == 'R'){
cout << "Player1" << endl;
}else if(s1[0] == s2[0]){
cout << "Tie" << endl;
}else{
cout << "Player2" << endl;
}
}
return 0;
}
//1250
#include<bits/stdc++.h>
using namespace std;
char a[125],b[125];
int main(){
cin >> a >> b;
for(int i = 0;i < strlen(a);i++){
if(a[i] >= 'A' && a[i] <= 'Z') a[i] += 'a' - 'A';
}
for(int i = 0;i < strlen(b);i++){
if(b[i] >= 'A' && b[i] <= 'Z') b[i] += 'a' - 'A';
}
if(strcmp(a,b) == 0) cout << "yes";
else cout << "no";
return 0;
}
//1625
#include<bits/stdc++.h>
using namespace std;
char a[55],b[55],n[55];
int main(){
cin >> a >> b;
if(strcmp(a,b) > 0){
strcat(a,b);
strcpy(n,a);
}else{
strcat(b,a);
strcpy(n,b);
}
for(int i = 1;i < strlen(n);i += 2){
cout << n[i];
}
return 0;
}
//1119
#include<bits/stdc++.h>
using namespace std;
int f = 1;
char a[85];
int main(){
cin >> a;
int len = strlen(a);
for(int i = 0;i < len;i++){
if(a[i] != a[len - 1 - i]) f = 0;
}
if(f) cout << "yes";
else cout << "no";
return 0;
}
*/
//22
/*
//1625
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main(){
cin >> a >>b;
if(a >= b) a += b;
else b += a,a = b;
for(int i = 0;i < a.size();i++){
if(i % 2) cout << a[i];
}
return 0;
}
//1254
#include<bits/stdc++.h>
using namespace std;
string a,b,c,t;
int main(){
cin >> a >> b >> c;
if(a > b){
t = a;
a = b;
b = t;
}if(b > c){
t = b;
b = c;
c = t;
}if(a > b){
t = a;
a = b;
b = t;
}
cout << a << " " << b << " " << c;
return 0;
}
//1624
#include<bits/stdc++.h>
using namespace std;
string x,a,e;
int main(){
cin >> x;
for(int i = 0;i < x.size();i++)
{
if(i % 2) a += x[i];
else e += x[i];
}
if(a >= e)
{
cout << a + e;
}
else
{
cout << e + a;
}
return 0;
}
//1363
#include<bits/stdc++.h>
using namespace std;
string a;
int f = 1;
int main()
{
cin >> a;
for(int i = 0;i < a.size() - 2;i++)
{
if(a[i] == 's' && a[i + 1] == 'o' && a[i + 2] == 's')
{
f = 0;
break;
}
}
if(f) cout << "NO";
else cout << "YES";
return 0;
}
//1117
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
cin >> n;
while(n--)
{
string s;
cin >> s;
int sum = 0;
int sc = 0;
for(int i = 0;i < s.size();i++)
{
if(s[i] == 'O')
{
sum += ++sc;
}else
{
sc = 0;
}
}
cout << sum << endl;
}
return 0;
}
//1671
#include<bits/stdc++.h>
using namespace std;
string s,s1;
int main()
{
cin >> s1 >> s;
int len = s1.size();
for(int i = 0;i < s.size();)
{
if(s.substr(i,len) == s1){
cout << "#";
i += len;
}else{
cout << s[i];
i++;
}
}
return 0;
}
//1672
#include<bits/stdc++.h>
using namespace std;
string s,a,mx,c;
int main()
{
cin >> s;
for(int i = 0;i < s.size();i++)
{
c = s[i];
if(c != "#"){
a += c;
}else{
if(a > mx) mx = a;
a = "";
}
}
cout << mx;
return 0;
}
//1336
#include<bits/stdc++.h>
using namespace std;
string s;
char c;
int x,y;
int main()
{
cin >> s;
for(int i = 0;i < s.size();i++)
{
c = s[i];
switch(c){
case 'R': x += 1; break;
case 'L': x -= 1; break;
case 'T': y += 1; break;
case 'D': y -= 1;
}
}
cout << x << " " << y;
return 0;
}
//1343
#include<bits/stdc++.h>
using namespace std;
int t;
int main()
{
cin >> t;
while(t--)
{
string a = "";
cin >> a;
for(int i = 0;i < a.size();i++){
if(a[i] == 'a' || a[i] == 'e' || a[i] == 'i' || a[i] == 'y' || a[i] == 'o' || a[i] == 'u')
{
if(i != 0)
{
continue;
}
}
cout << a[i];
}
cout << endl;
}
return 0;
}
//1839
#include<bits/stdc++.h>
using namespace std;
int f = 1;
string a,b;
int main()
{
cin >> a >> b;
int len = b.size();
for(int i = 0;i < a.size();i++)
{
if(a.substr(i,len) == b)
{
f = 0;
break;
}
}
len = a.size();
for(int i = 0;i < b.size();i++)
{
if(b.substr(i,len) == a)
{
f = 0;
break;
}
}
if(f) cout << "No substring" << endl;
else cout << "substring" << endl;
return 0;
}
*/
//23
/*
//1643
#include<bits/stdc++.h>
using namespace std;
int a[10005],n,f = 1;
int main(){
cin >> n;
for(int i = 1;i <= n;i++) cin >> a[i];
for(int i = 1;i <= n - 1;i++){
for(int j = i + 1;j <= n;j++){
if(a[i] == a[j]) f = 0;
}
}
if(f) cout << "NO";
else cout << "YES";
return 0;
}
//1644
#include<bits/stdc++.h>
using namespace std;
int a[10005],n,f = 1;
int main(){
cin >> n;
for(int i = 1;i <= n;i++) cin >> a[i];
for(int i = 1;i <= n - 1;i++){
for(int j = i + 1;j <= n;j++){
if(a[i] == a[j] * 2 || a[i] * 2 == a[j]) f = 0;
}
}
if(f) cout << "NO";
else cout << "YES";
return 0;
}
//1645
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
cin >> s;
int len = s.size(),f = 1;
char c_new,c_old;
for(int i = 1;i < len;i++){
c_new = s[i];
c_old = s[i - 1] + 1;
if(c_new != c_old){
f = 0;
break;
}
}
if(f) cout << "YES";
else cout << "NO";
return 0;
}
//1646
#include<bits/stdc++.h>
using namespace std;
int a[105][105],m,k,n,cnt; //m个火把,k个萤石
int main(){
cin >> n >> m >> k;
while(m--){
int x,y;
cin >> x >> y;
a[x][y] = 1;
a[x-1][y] = 1;
a[x+1][y] = 1;
a[x][y+1] = 1;
a[x][y-1] = 1;
a[x-1][y+1] = 1;
a[x+1][y+1] = 1;
a[x-1][y-1] = 1;
a[x+1][y-1] = 1;
a[x][y+2] = 1;
a[x][y-2] = 1;
a[x-2][y] = 1;
a[x+2][y] = 1;
}
while(k--){
int x,y;
cin >> x >> y;
a[x][y] = 1;
a[x-1][y] = 1;
a[x+1][y] = 1;
a[x][y+1] = 1;
a[x][y-1] = 1;
a[x-1][y+1] = 1;
a[x+1][y+1] = 1;
a[x-1][y-1] = 1;
a[x+1][y-1] = 1;
a[x][y+2] = 1;
a[x][y-2] = 1;
a[x-2][y] = 1;
a[x+2][y] = 1;
a[x-2][y+2] = 1;
a[x-2][y+1] = 1;
a[x-1][y+2] = 1;
a[x-2][y-1] = 1;
a[x-2][y-2] = 1;
a[x-1][y-2] = 1;
//===============
a[x+1][y+2] = 1;
a[x+2][y+1] = 1;
a[x+2][y+2] = 1;
a[x+2][y-1] = 1;
a[x+1][y-2] = 1;
a[x+2][y-2] = 1;
}
for(int i = 1;i <= n;i++){
for(int j = 1;j <= n;j++){
if(a[i][j] == 0) cnt++;
}
}
cout << cnt;
return 0;
}
//1339
#include<bits/stdc++.h>
using namespace std;
int a[10005],n,f = 1,ans;
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> a[i];
}
for(int i = 2;i <= n;i++){
if(a[i] == a[1]) f = 0;
else ans = a[i];
}
if(f) cout << a[1];
else cout << ans;
return 0;
}
//1647
#include<bits/stdc++.h>
using namespace std;
string s;
int cnt,h = 1;
int main(){
cin >> s;
int len = s.size();
for(int i = 0;i < len;i++){
if(s[i] == '#'){
h = 1;
continue;
}
else if(s[i] >= 'a' && s[i] <= 'z' && h == 1){
h = 0;
cnt += 1;
}
}
cout << cnt;
return 0;
}
//1808
#include<bits/stdc++.h>
using namespace std;
int a[1005],n,mx = -2147483647,cnt;
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> a[i];
mx = max(mx,a[i]);
}
for(int i = 1;i <= n;i++){
if(a[i] == mx) cnt++;
}
cout << cnt;
return 0;
}
//1649
#include<bits/stdc++.h>
using namespace std;
int n,m;
char c[105][105];
int main(){
cin >> n >> m;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++){
cin >> c[i][j];
}
}
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++){
if(c[i][j] == '?'){
int cnt = 0;
if(c[i - 1][j + 1] == '*') cnt++;
if(c[i][j + 1] == '*') cnt++;
if(c[i + 1][j + 1] == '*') cnt++;
if(c[i - 1][j] == '*') cnt++;
if(c[i + 1][j] == '*') cnt++;
if(c[i - 1][j - 1] == '*') cnt++;
if(c[i][j - 1] == '*') cnt++;
if(c[i + 1][j - 1] == '*') cnt++;
c[i][j] = '0' + cnt;
}
}
}
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++){
cout << c[i][j];
}
cout << endl;
}
return 0;
}
*/
//24
/*
//1029
#include<bits/stdc++.h>
using namespace std;
int a[1005];
int main(){
int n;
cin >> n;
for(int i = 1;i <= n;i++){
cin >> a[i];
}
sort(a + 1,a + n + 1);
for(int i = 1;i <= n;i++) cout << a[i] << " ";
return 0;
}
//1017
#include<bits/stdc++.h>
using namespace std;
int a[1005],cnt;
double score;
int main(){
int n;
cin >> n;
for(int i = 1;i <= n;i++){
cin >> a[i];
score += a[i];
}
score /= n;
for(int i = 1;i <= n;i++) if(a[i] < score) cnt++;
cout << cnt;
return 0;
}
//1674
#include<bits/stdc++.h>
using namespace std;
int a[10][10];
int main(){
for(int i = 1;i <= 5;i++){
for(int j = 1;j <= 5;j++){
cin >> a[i][j];
}
}
for(int i = 1;i <= 5;i++){
for(int j = 1;j <= 5;j++){
int f = 1;
for(int k = 1;k <= 5;k++){
if(a[i][k] > a[i][j]){
f = 0;
break;
}
}
for(int k = 1;k <= 5;k++){
if(a[k][j] < a[i][j]){
f = 0;
break;
}
}
if(f){
cout << i << " " << j << " " << a[i][j];
return 0;
}
}
}
cout << "not found" << endl;
return 0;
}
//1251
#include<bits/stdc++.h>
using namespace std;
char ci[30],s[105],c;
int main(){
for(int i = 0;i < 26;i++){
cin >> c;
ci[c - 'a'] = i;
//cout << c - 'a' << " ";
//cout << ci[c - 'a'] << " ";
}
cin >> s;
for(int i = 0;i < strlen(s);i++){
s[i] = ci[s[i] - 'a'] + 'a';
cout << s[i];
}
return 0;
}
//1675
#include<bits/stdc++.h>
using namespace std;
string s;
long long ans = 1,num;
int main(){
cin >> s;
int len = s.size();
for(int i = 0;i < len;i++){
//num = 0;
if(s[i] == '*'){
ans *= num;
num = 0;
}else{
num = num * 10 + s[i] - '0';
}
//cout << num << endl;
}
ans *= num;
cout << ans;
return 0;
}
//1676
#include<bits/stdc++.h>
using namespace std;
string s;
char a;
int cnt = 1;
int main(){
cin>>s;
for(int i = 0;i < s.size();i++){
if('a' <= s[i] && s[i] <= 'z') s[i] -= 'a' - 'A';
}
a = s[0];
for(int i = 1;i < s.size();i++){
if(s[i] == a){
cnt++;
}else{
cout<<'('<<a<<','<<cnt<<')';
cnt = 1;
a = s[i];
}
}
cout<<'('<<a<<','<<cnt<<')';
return 0;
}
//2589
#include<bits/stdc++.h>
using namespace std;
int a[105][105],n,m;
int main(){//n-j+1
cin >> n >> m;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++){
cin >> a[i][j];
}
}
for(int i = 1;i <= m;i++){
for(int j = 1;j <= n;j++){
cout << a[n - j + 1][i] << " ";
}
cout << endl;
}
return 0;
}
//1234
#include<bits/stdc++.h>
using namespace std;
string s;
int maxlen = 1,l,cnt = 0,len = 1;
int main(){
cin >> s;
l = s.size();
for(int i = 0;i < l - 1;i++){
if(s[i + 1] == s[i]){
len++;
if(len > maxlen) maxlen = len;
}
else{
len = 1;
}
}
if(maxlen == 1){
cout << maxlen << " " << s.size() << endl;
}else{
len = 1;
for(int i = 0;i < l;i++){
if(i < l - 1 && s[i + 1] == s[i]) len ++;
else{
if(len == maxlen) cnt++;
len = 1;
}
}
cout << maxlen << " " << cnt;
}
return 0;
}
*/
//三综测
/*
//1633
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
cin >> s;
int l = s.size();
for(int i = 0;i < l;i++){
if(s[i] == 'A') cout << 'T';
else if(s[i] == 'T') cout << 'A';
else if(s[i] == 'G') cout << 'C';
else if(s[i] == 'C') cout << 'G';
}
return 0;
}
//2072
#include<bits/stdc++.h>
using namespace std;
int n,last_a,a,f = 1;
int main(){
cin >> n >> last_a;
for(int i = 2;i <= n;i++){
cin >> a;
if(last_a <= a) f = 0;
last_a = a;
}
if(f) cout << "NO";
else cout << "YES";
return 0;
}
//1432
#include<bits/stdc++.h>
using namespace std;
int n,m,a[10005],c,f = 1;
int main(){
cin >> n >> m;
for(int i = 1;i <= m;i++){
cin >> c;
a[c] = 1;
}
for(int i = 1;i <= n;i++){
if(a[i] == 0){
cout << i << " ";
f = 0;
}
}
if(f) cout << "555~~~";
return 0;
}
//2071
#include<bits/stdc++.h>
using namespace std;
const int mod = 11;
string s;
int sum;
int main(){ //ISBN号码下标从零开始最后一位是s[12]
cin >> s;
int l = s.size(),n = 1;
for(int i = 0;i < l - 1;i++){
if(s[i] == '-') continue;
sum += (s[i] - '0') * n;
//cout << s[i] - '0' << " ";
//cout << s[i] - '0' << " X " << n << endl;
n += 1;
}
//cout << endl << sum;
sum %= mod;
//cout << sum << " " << s[12] << endl;
if(sum == 10 && s[12] == 'X' || sum == s[12] - '0'){
cout << "Right";
}else{
for(int i = 0;i <= 11;i++){
cout << s[i];
}
if(sum == 10) cout << "X";
else cout << sum;
}
return 0;
}
//1120
#include<bits/stdc++.h>
using namespace std;
string s;
int k;
int main(){
cin >> s >> k;
int c = 1,l = s.size(),f = 1;
for(int i = 0;i < l - 1;i++){
if(s[i] == s[i + 1]) c++;
else c = 1;
if(c >= k){
cout << s[i];
f = 0;
break;
}
}
if(f) cout << "no";
return 0;
}
*/
//33
/*
//1008
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
cin >> a >> b >> c;
cout << max(a,max(b,c));
return 0;
}
//2086
#include<bits/stdc++.h>
using namespace std;
int n;
bool is_prime(int a){
int f = 1;
if(a == 1) return false;
for(int i = 2;i < a;i++){
if(a % i == 0){
f = 0;
}
}
if(f) return true;
else return false;
}
int main(){
cin >> n;
if(is_prime(n)){
cout << "yes";
}else{
cout << "no";
}
return 0;
}
//1360
#include<bits/stdc++.h>
using namespace std;
int a,b,cnt;
bool is_prime(int a){
int f = 1;
if(a == 1) return false;
for(int i = 2;i < a;i++){
if(a % i == 0){
f = 0;
}
}
if(f) return true;
else return false;
}
int main(){
cin >> a >> b;
for(int i = a;i <= b;i++){
if(is_prime(i)){
cnt += i;
}
}
cout << cnt;
return 0;
}
//1406
#include<bits/stdc++.h>
using namespace std;
int n,cnt;
int count_the_number_of_ones(int n){
int cnt = 0;
while(n){
if(n % 10 == 1) cnt ++;
n /= 10;
}
return cnt;
}
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cnt += count_the_number_of_ones(i);
}
cout << cnt;
return 0;
}
//1474
#include<bits/stdc++.h>
using namespace std;
long long n,cnt;
long long summation_instrument(int n){ //本函数返回值必须开long long
long long cnt = 1;
for(int i = 1;i <= n;i++){
cnt *= i;
}
return cnt;
}
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cnt += summation_instrument(i);
}
cout << cnt;
return 0;
}
//2635
#include<bits/stdc++.h>
using namespace std;
int n,cnt,c;
bool determine_whether_the_year_is_special(int n){
int g,s,b,q;
g = n % 10;
n /= 10;
s = n % 10;
n /= 10;
b = n % 10;
n /= 10;
q = n % 10;
if(q == s && b + 1 == g){
return true;
}
return false;
}
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> c;
if(determine_whether_the_year_is_special(c)) cnt ++;
}
cout << cnt;
return 0;
}
//1361
#include<bits/stdc++.h>
using namespace std;
bool determine_whether_this_number_is_a_narcissistic_number(int n){
int g,s,b,a = n;
g = a % 10;
a /= 10;
s = a % 10;
a /= 10;
b = a % 10;
if(g * g * g + s * s * s + b * b * b == n) return true;
return false;
}
int main(){
int l,r,f = 1;
cin >> l >> r;
for(int i = l;i <= r;i++){
if(determine_whether_this_number_is_a_narcissistic_number(i)){
cout << i << " ";
f = 0;
}
}
if(f) cout << "no" << endl;
return 0;
}
*/
//34
/*
//2597
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,f;
int main(){
cin >> a >> b >> c >> d >> e >> f;
d = abs(d);
e = abs(e);
f = abs(f);
cout << max(a,d) << " " << max(b,e) << " " << max(c,f);
return 0;
}
//1010
#include<bits/stdc++.h>
using namespace std;
int a[10];
int main(){
cin >> a[1] >> a[2] >> a[3];
sort(a + 1,a + 4);
cout << a[1] << " " << a[2] << " " << a[3];
return 0;
}
//1015
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main(){
cin >> a >> b;
cout << ceil(1.0 * a / b);
return 0;
}
//1334
#include<bits/stdc++.h>
using namespace std;
double n;
int main(){
cin >> n;
int a = ceil(sqrt(n));
if(a == sqrt(n)) cout << "yes" << endl;
else cout << "no" << endl;
return 0;
}
//1341
#include<bits/stdc++.h>
using namespace std;
int n;
int is_palindrome_number(int a){
int b = a,sum = 0;
while(b){
sum = sum * 10 + b % 10;
b /= 10;
}
if(sum == a) return true;
return false;
}
int is_prime(int a){
if(a == 1) return false;
for(int i = 2;i < a;i++){
if(a % i == 0) return false;
}
return true;
}
int main(){
cin >> n;
if(is_palindrome_number(n) && is_prime(n)){
cout << "yes" << endl;
}else{
cout << "no" << endl;
}
return 0;
}
//2598
#include<bits/stdc++.h>
using namespace std;
string a,b,s;
string string_generator(string x,string c,string s){
string n = "";
int len = s.size();
for(int i = 0;i < len;i++){
if(s[i] == 'a') n += x;
else n += c;
}
return n;
}
bool is_a_palindrome_string(string s){
int len = s.size();
string a = "";
for(int i = len - 1;i >= 0;i--){
a += s[i];
}
if(a == s) return true;
return false;
}
char string_type(string s){
char t = 'X';
for(int i = 0;i < s.size();i++){
if(s[i] >= 'a' && s[i] <= 'z' || s[i] >= 'A' && s[i] <= 'Z'){
if(t == 'n'){
t = 's';
return t;
}
t = 'l';
}
if(s[i] >= '0' && s[i] <= '9'){
if(t == 'l'){
t = 's';
return t;
}
t = 'n';
}
}
return t;
}
int main(){
cin >> a >> b >> s;
string n = string_generator(a,b,s);
//cout << n;
string palindrome = "null";
if(is_a_palindrome_string(n)) palindrome = "palindrome";
else palindrome = "non-palindrome";
string type = "null";
if(string_type(n) == 's') type = "string";
else if(string_type(n) == 'l') type = "letter";
else type = "number";
//cout << is_a_palindrome_string(n) << endl;
cout << palindrome << endl << type;
return 0;
}
//1358
#include<bits/stdc++.h>
using namespace std;
int n;
int change_to_reverse_order(int a){
int b = a,sum = 0;
while(b){
sum = sum * 10 + b % 10;
b /= 10;
}
return sum;
}
int is_prime(int a){
if(a == 1) return false;
for(int i = 2;i < a;i++){
if(a % i == 0) return false;
}
return true;
}
int main(){
cin >> n;
n = change_to_reverse_order(n);
if(is_prime(n)) cout << "YES" << endl;
else cout << "NO" << endl;
return 0;
}
//1375
#include<bits/stdc++.h>
using namespace std;
int l,r;
bool self_divisible_number(int n){
int len = 0,b = n,a[10] = {0};
while(b){
len += 1;
a[len] = b % 10;
b /= 10;
}
for(int i = 1;i <= len;i++){
if(a[i] == 0 || n % a[i] != 0){
return false;
}
}
return true;
}
int main(){
cin >> l >> r;
for(int i = l;i <= r;i++){
if(self_divisible_number(i)) cout << i << " ";
}
return 0;
}
*/
//35
/*
//1029
#include<bits/stdc++.h>
using namespace std;
int a[1005],n;
int main(){
cin >> n;
for(int i = 1;i <= n;i++) cin >> a[i];
sort(a + 1,a + n + 1);
for(int i = 1;i <= n;i++) cout << a[i] << " ";
return 0;
}
//1254
#include<bits/stdc++.h>
using namespace std;
string s[10];
int main(){
cin >> s[1] >> s[2] >> s[3];
sort(s + 1,s + 4);
cout << s[1] << endl << s[2] << endl << s[3] << endl;
return 0;
}
//2601
#include<bits/stdc++.h>
using namespace std;
int n,a[105];
bool cmp(int a,int b){
if(a % 10 == 0 && b % 10 != 0) return true;
if(a % 10 != 0 && b % 10 == 0) return false;
if(a % 10 == 0 && b % 10 == 0) return a > b;
return a > b;
}
int main(){
cin >> n;
for(int i = 1;i <= n;i++) cin >> a[i];
sort(a + 1,a + n + 1,cmp);
for(int i = 1;i <= n;i++) cout << a[i] << " ";
return 0;
}
//2602
#include<bits/stdc++.h>
using namespace std;
int n,a[105];
bool cmp(int a,int b){
int c_a = 0,c_b = 0;
while(a){
c_a += a % 10;
a /= 10;
}
while(b){
c_b += b % 10;
b /= 10;
}
return c_a > c_b;
}
int main(){
cin >> n;
for(int i = 1;i <= n;i++) cin >> a[i];
sort(a + 1,a + n + 1,cmp);
for(int i = 1;i <= n;i++) cout << a[i] << " ";
return 0;
}
//2603
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main(){
scanf("%d%d",&a,&b);
printf("%d+%d=%d\n",a,b,a + b);
printf("%d-%d=%d\n",a,b,a - b);
printf("%d*%d=%d\n",a,b,a * b);
printf("%d/%d=%.3f\nover\n",a,b,1.0 * a / b);
return 0;
}
//2235
#include<bits/stdc++.h>
using namespace std;
int n,a;
int main(){
scanf("%d",&n);
for(int i = 1;i <= n;i++){
scanf("%d",&a);
printf("%d ",a);
}
return 0;
}
//1247
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
getline(cin,s);
cout << s;
return 0;
}
//1487
#include<bits/stdc++.h>
using namespace std;
double d;
int main(){
cin >> d;
printf("%.3f",d);
return 0;
}
//2604
#include<bits/stdc++.h>
using namespace std;
string s[100005];
int n;
bool cmp(string a,string b){
int c1 = 0,c2 = 0;
for(int i = 0;i < a.size();i++){
if(a[i] == 'A' || a[i] == 'a' || a[i] == 'm' || a[i] == 'M') c1++;
}
for(int i = 0;i < b.size();i++){
if(b[i] == 'A' || b[i] == 'a' || b[i] == 'm' || b[i] == 'M') c2++;
}
return c1 > c2;
}
int main(){
cin >> n;
for(int i = 1;i <= n;i++) cin >> s[i];
sort(s + 1,s + n + 1,cmp);
for(int i = 1;i <= n;i++) cout << s[i] << " ";
return 0;
}
//2606
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int n;
bool cmp(int a,int b){
if(a % 10 == b % 10) return a < b;
return a % 10 < b % 10;
}
int main(){
cin >> n;
for(int i = 1;i <= n;i++) cin >> a[i];
sort(a + 1,a + n + 1,cmp);
for(int i = 1;i <= n;i++) cout << a[i] << " ";
return 0;
}
*/
//36
/*
//2644
#include<bits/stdc++.h>
using namespace std;
struct book{
string name,author;
double price;
};
int main(){
book a;
cin >> a.name >> a.author >> a.price;
printf("%.2f\n",1.0 * a.price * 0.8);
return 0;
}
//1371
#include<bits/stdc++.h>
using namespace std;
int n;
struct student{
int id,score;
string name,gender;
}s[105];
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> s[i].id >> s[i].name >> s[i].gender >> s[i].score;
}
for(int i = n;i >= 1;i--){
cout << s[i].id << " " << s[i].name << " " << s[i].gender << " " << s[i].score << endl;
}
return 0;
}
//2111
#include<bits/stdc++.h>
using namespace std;
int n;
struct pen{
string name;
int price;
}p[105];
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> p[i].name >> p[i].price;
if(p[i].name == "hero"){
cout << p[i].name << " " << p[i].price << endl;
}
}
for(int i = 1;i <= n;i++){
if(p[i].name == "deli"){
cout << p[i].name << " " << p[i].price << endl;
}
}
return 0;
}
//2645
#include<bits/stdc++.h>
using namespace std;
int n;
struct student{
string name;
int chinese_score,math_score,english_score,gross;
}s[105];
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> s[i].name >> s[i].chinese_score >> s[i].math_score >> s[i].english_score;
s[i].gross = s[i].chinese_score + s[i].english_score + s[i].math_score;
}
for(int i = 1;i <= n;i++){
for(int j = i + 1;j <= n;j++){
if(abs(s[i].chinese_score - s[j].chinese_score) <= 5 && abs(s[i].english_score - s[j].english_score) <= 5 && abs(s[i].math_score - s[j].math_score) <= 5 && abs(s[i].gross - s[j].gross) <= 10){
cout << s[i].name << " " << s[j].name << endl;
}
}
}
return 0;
}
//1667
#include<bits/stdc++.h>
using namespace std;
int n,m,mx = -2147483647,f = 1;
struct take_out{
string name;
int price,popularity_degree;
}t[100005];
int main(){
cin >> n >> m;
for(int i = 1;i <= n;i++){
cin >> t[i].name >> t[i].price >> t[i].popularity_degree;
if(t[i].price <= m){
f = 0;
mx = max(t[i].popularity_degree,mx);
}
}
for(int i = 1;i <= n;i++){
if(t[i].popularity_degree == mx){
cout << t[i].name << " " << t[i].price << " " << t[i].popularity_degree;
}
}
if(f) cout << "...>_<..." << endl;
return 0;
}
//1491
#include<bits/stdc++.h>
using namespace std;
int n;
struct book{
int id;
string name,author;
}b[105];
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> b[i].id >> b[i].name >> b[i].author;
if(b[i].author == "wlxsq"){
cout << b[i].id << " " << b[i].name << " " << b[i].author << endl;
}
}
return 0;
}
//2646
#include<bits/stdc++.h>
using namespace std;
int n,mx = -2147483647;
struct student{
string name;
int chinese_score,math_score,english_score,gross;
}s[105];
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> s[i].name >> s[i].chinese_score >> s[i].math_score >> s[i].english_score;
s[i].gross = s[i].chinese_score + s[i].english_score + s[i].math_score;
mx = max(mx,s[i].gross);
}
for(int i = 1;i <= n;i++){
if(s[i].gross == mx){
cout << s[i].name << " " << s[i].chinese_score << " " << s[i].math_score << " " << s[i].english_score << endl;
break;
}
}
return 0;
}
*/
//37
/*
//2651
#include<bits/stdc++.h>
using namespace std;
int n;
struct student{
string name;
int score;
}s[55];
bool cmp(student a,student b){
return a.score > b.score;
}
int main(){
cin >> n;
for(int i = 1;i <= n;i++) cin >> s[i].name >> s[i].score;
sort(s + 1,s + n + 1,cmp);
for(int i = 1;i <= n;i++){
cout << s[i].name << " " << s[i].score << endl;
}
return 0;
}
//2082
#include<bits/stdc++.h>
using namespace std;
int n;
struct String{
string str;
int len,one_cnt;
}s[105];
int the_number_of_ones(string a){
int cnt = 0,l = a.size();
for(int i = 0;i < l;i++){
if(a[i] == '1') cnt++;
}
return cnt;
}
bool cmp(String a,String b){
if(a.len != b.len) return a.len < b.len;
if(a.one_cnt != b.one_cnt) return a.one_cnt < b.one_cnt;
return a.str < b.str;
}
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> s[i].str;
s[i].len = s[i].str.size();
s[i].one_cnt = the_number_of_ones(s[i].str);
}
sort(s + 1,s + n + 1,cmp);
for(int i = 1;i <= n;i++){
cout << s[i].str << endl;
}
return 0;
}
//2652
#include<bits/stdc++.h>
using namespace std;
int n;
struct student{
string name,gender;
int year,month,id;
}s[105];
bool cmp(student a,student b){
if(a.year != b.year) return a.year > b.year;
if(a.month != b.month) return a.month > b.month;
return a.id < b.id;
}
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> s[i].name >> s[i].gender >> s[i].year >> s[i].month;
s[i].id = i;
}
sort(s + 1,s + n + 1,cmp);
for(int i = 1;i <= n;i++){
cout << s[i].name << endl;
}
return 0;
}
//2653
#include<bits/stdc++.h>
using namespace std;
int n,score,mx = -2147483647,mn = 2147483647,f1 = 0,f2 = 0;
string name,id;
char gender;
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> name >> gender >> id >> score;
if(gender == 'M') mn = min(mn,score),f1++;
else mx = max(mx,score),f2++;
}
if(f1 == 0 || f2 == 0){
cout << "NA" << endl;
return 0;
}
cout << abs(mx - mn);
return 0;
}
//1354
#include<bits/stdc++.h>
using namespace std;
int n,ans = INT_MAX;
struct food{
int ps,zt;
}f[25];
bool cmp(food a,food b){
return a.ps < b.ps;
}
int main(){
cin >> n;
for(int i = 1;i <= n;i++) cin >> f[i].ps;
for(int i = 1;i <= n;i++) cin >> f[i].zt;
sort(f + 1,f + n + 1,cmp);
for(int i = 0;i <= n;i++){
int sum = 0;
for(int j = i + 1;j <= n;j++){
sum += f[j].zt;
}
int x = max(f[i].ps,sum);
ans = min(ans,x);
}
cout << ans;
return 0;
}
//1081
#include<bits/stdc++.h>
using namespace std;
int n;
struct student{
string name;
int chinese_score,maths_score,score;
}s[25];
bool cmp(student a,student b){
return a.score > b.score;
}
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> s[i].name >> s[i].chinese_score >> s[i].maths_score;
s[i].score = s[i].chinese_score + s[i].maths_score;
}
sort(s + 1,s + n + 1,cmp);
for(int i = 1;i <= n;i++){
cout << s[i].name << endl;
}
return 0;
}
//1337
#include<bits/stdc++.h>
using namespace std;
int n,max_id = -1;
double mx = -2147483647;
struct student{
double strength,potential,id,comprehensive_strength;
}s[105];
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> s[i].strength >> s[i].potential;
s[i].id = i;
s[i].comprehensive_strength = s[i].strength + s[i].potential / 2;
//cout << s[i].comprehensive_strength << endl;
//cout << mx << endl;
//cout << (s[i].comprehensive_strength > mx) << endl;
if(s[i].comprehensive_strength > mx) mx = s[i].comprehensive_strength,max_id = i;
}
cout << max_id;
return 0;
}
//1665
#include<bits/stdc++.h>
using namespace std;
int n,a[25];
int main(){
cin >> n;
for(int i = 1;i <= n;i++) cin >> a[i];
for(int i = 1;i <= n;i++){
int sum = 0;
for(int j = 1;j <= n;j++){
if(a[j] < a[i]) sum++;
}
cout << sum + 1 << " ";
}
return 0;
}
//1658
#include<bits/stdc++.h>
using namespace std;
string s[10];
bool cmp(string a,string b){
if(a.size() != b.size()) return a.size() > b.size();
return a > b;
}
int main(){
for(int i = 1;i <= 5;i++) getline(cin,s[i]);
sort(s + 1,s + 6,cmp);
for(int i = 1;i <= 5;i++) cout << s[i] << endl;
return 0;
}
*/
//38
/*
//1020
#include<bits/stdc++.h>
using namespace std;
int n,x;
vector<int> v;
int main(){
ios::sync_with_stdio(false);
cin >> n;
for(int i = 1;i <= n;i++){
cin >> x;
v.push_back(x);
}
for(int i = v.size() - 1;i >= 0;i--){
cout << v[i] << " ";
}
return 0;
}
//1493
#include<bits/stdc++.h>
using namespace std;
int n,m,x;
vector<int> v[100005];
int main(){
ios::sync_with_stdio(false);
cin >> n >> m;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++){
cin >> x;
v[i].push_back(x);
}
}
for(int i = 1;i <= n;i++){
for(int j = 0;j < m;j++){
cout << v[i][j] << " ";
}
cout << '\n';
}
return 0;
}
//1020
#include<bits/stdc++.h>
using namespace std;
int n,x;
deque<int> d;
int main(){
ios::sync_with_stdio(false);
cin >> n;
for(int i = 1;i <= n;i++){
cin >> x;
d.push_front(x);
}
for(int i = 0;i < n;i++) cout << d[i] << " ";
return 0;
}
//2614
#include<bits/stdc++.h>
using namespace std;
int t,n;
deque<int> d;
int main(){
ios::sync_with_stdio(false);
cin >> t >> n;
for(int i = 1;i <= n;i++){
d.push_back(i);
}
while(t--){
d.push_back(d[0]);
d.pop_front();
}
cout << d[0];
return 0;
}
//2615
#include<bits/stdc++.h>
using namespace std;
int n,m,M;
deque<int> d;
//记录小朋友序号
int a[10005];
//记录糖果数
int main(){
ios::sync_with_stdio(false);
cin >> n >> m >> M;
//小朋友数目
//每次分的糖果数目
//工作人员准备的糖果总数
for(int i = 1;i <= n;i++) d.push_back(i);
while(M > 0){
if(M > m){
a[d[0]] += m;
M -= m;
d.push_back(d[0]);
d.pop_front();
}
else{
a[d[0]] += M;
M = 0;
}
}
for(int i = 0;i < n;i++){
cout << d[i] << " " << a[d[i]] << endl;
}
return 0;
}
//2616
#include<bits/stdc++.h>
using namespace std;
int n,m,x;
deque<int> d;
bool cmp(int a,int b){
return a > b;
}
int main(){
ios::sync_with_stdio(false);
cin >> n >> m;
for(int i = 1;i <= m;i++){
cin >> x;
if(x % 2){
d.push_back(x);
}else{
d.push_front(x);
}
}
for(int i = 1;i <= n - m;i++){
cin >> x;
if(x % 2){
d.push_back(x);
d.pop_front();
}else{
d.push_front(x);
d.pop_back();
}
}
sort(d.begin(),d.end(),cmp);
for(int i = 0;i < m;i++) cout << d[i] << " ";
return 0;
}
//2613
#include<bits/stdc++.h>
using namespace std;
int n,m;
deque<string> d;
string s;
int main(){
scanf("%d",&n);
scanf("%d",&m);
for(int i = 1;i <= n;i++){
cin >> s;
d.push_back(s);
}
int now_num = m;
while(d.size() != 1){
if(now_num % 7 == 0){
//cout <<"delete:" << d[0] << endl;
now_num += 1;
d.pop_front();
}
//cout << d[0] << "报出了" << now_num << endl;
d.push_back(d[0]);
d.pop_front();
now_num += 1;
}
cout << d[0];
return 0;
}
*/
//39
/*
//1369
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
int main(){
ios::sync_with_stdio(false);
cin >> n;
while(n--){
cin >> a >> b;
cout << a << " " << b << " " << (a * b) << " " << (a * 2 + b * 2) << endl;
}
return 0;
}
//1094
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
ios::sync_with_stdio(false);
while(cin >> a){
cin >> b >> c;
int f = 1;
for(int i = 10;i <= 100;i++){
if(i % 3 == a && i % 5 == b && i % 7 == c){
f = 0;
cout << i << endl;
break;
}
}
if(f) cout << "no answer" << endl;
}
return 0;
}
//2631
#include<bits/stdc++.h>
using namespace std;
string s,a,fw;
int n,cnt;
int slove(string s,string a){
//cout<<" 读入"<<a<<'\n';
string add="";
int len=a.size(),c=0;
for(int i=0;i<=len;i++){
if(a[i]==' ' || len - i == 0){
if(s==add){
c++;
//cout<<" c++"<<'\n';
}
add="";
//cout<<" add清空"<<add<<'\n';
continue;
}
add+=a[i];
//cout<<"slove_add:"<<add<<'\n';
}
return c;
}
int main(){
ios::sync_with_stdio(false);
cin>>s>>n;
getline(cin,fw);
//前面输入s和n的时候回车还没输入
//会导致第一行getline吃到\n
while(n--){
getline(cin,a);
cnt+=slove(s,a);
//cout<<"主循环cnt:"<<cnt<<'\n';
}
cout<<cnt;
return 0;
}
//2632
#include<bits/stdc++.h>
using namespace std;
struct node{
int x,y;
}a[1005];
bool cmp(node a,node b){
return a.x*a.x+a.y*a.y<b.x*b.x+b.y*b.y;
}
int n;
int main(){
//ios::sync_with_stdio(false);
while(cin>>n){
double ans=0;
for(int i=1;i<=n;i++) cin>>a[i].x>>a[i].y;
sort(a+1,a+n+1,cmp);
for(int i=1;i<=n;i++){
ans+=sqrt((a[i].x-a[i-1].x)*(a[i].x-a[i-1].x)+(a[i].y-a[i-1].y)*(a[i].y-a[i-1].y));
}
cout<<fixed<<setprecision(2)<<ans<<endl;
}
return 0;
}
//2633
#include<bits/stdc++.h>
using namespace std;
struct song{
int id,k;
}s[10005];
bool cmp(song a,song b){
return a.k > b.k;
}
int n,m,a,b,x,ex,mx = -2147483647,f = 0;
int main(){
ios::sync_with_stdio(false);
cin>>n>>m>>a>>b;
for(int i = 1;i <= a;i++){
for(int j = 1;j <= n;j++){
cin >> x;
s[j].k += x;
s[j].id = j;
if(i == b && x > mx){
mx = x;
ex = j;
}
}
}
sort(s + 1,s + n + 1,cmp);
for(int i = 1;i <= m;i++){
if(s[i].id == ex) f = 1;
}
if(f){
cout << ex << " ";
for(int i = 1;i <= m;i++){
if(ex == s[i].id) continue;
cout << s[i].id << " ";
}
}else{
for(int i = 1;i < m;i++){
cout << s[i].id << " ";
}
cout << ex;
}
return 0;
}
//1600
#include<bits/stdc++.h>
using namespace std;
deque<int> b,g;
int m,n,k;
int main(){
ios::sync_with_stdio(false);
cin >> m >> n >> k;
for(int i = 1;i <= m;i++){
b.push_back(i);
}
for(int i = 1;i <= n;i++){
g.push_back(i);
}
while(k--){
cout << b[0] << " " << g[0] << '\n';
b.push_back(b[0]);
g.push_back(g[0]);
b.pop_front();
g.pop_front();
}
return 0;
}
//2036
#include<bits/stdc++.h>
using namespace std;
struct student{
string name;
int age,NOIP_score;
}s[1005];
int n;
int main(){
ios::sync_with_stdio(false);
cin >> n;
for(int i = 1;i <= n;i++) cin >> s[i].name >> s[i].age >> s[i].NOIP_score;
for(int i = 1;i <= n;i++){
s[i].age += 1;
s[i].NOIP_score = s[i].NOIP_score * 1.2;
if(s[i].NOIP_score > 600) s[i].NOIP_score = 600;
cout << s[i].name << " " << s[i].age << " " << s[i].NOIP_score << endl;
}
return 0;
}
//2018
#include<bits/stdc++.h>
using namespace std;
int mx = -2147483647,mn = 2147483647,x,n,m,sum = 0;
double max_score = -2147483647;
int main(){
ios::sync_with_stdio(false);
cin >> n>>m;
for(int i = 1;i <= n;i++){
mx = -2147483647;
mn = 2147483647;
sum = 0;
for(int j = 1;j <= m;j++){
cin >> x;
sum += x;
if(x > mx) mx = x;
if(x < mn) mn = x;
}
//cout <<"sum:"<< sum << "max:" << mx << "min:" << mn<<endl;
sum = sum - mx - mn;
if(sum > max_score) max_score = sum;
}
cout <<fixed << setprecision(2)<< 1.0 * max_score / (m - 2) << endl;
return 0;
}
*/
//测验4
/*
//1678
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
#define fst ios::sync_with_stdio(false),cin.tie(),cout.tie();
#define ll long long
double a,b,c,p,ans;
int main(){
cin >> a >> b >> c;
p = (a + b +c) / 2;
ans = p * (p - a) * (p - b) * (p - c);
ans = sqrt(ans);
printf("%.2f",ans);
return 0;
}
//1679
#include<iostream>
//#include<cstdio>
#include<string>
//#include<vector>
//#include<deque>
//#include<cmath>
using namespace std;
#define fst ios::sync_with_stdio(false);
#define fast cin.tie(),cout.tie();
#define ll long long
#define endl '\n'
string s;
int cnt;
int main(){
fst
fast
getline(cin,s);
for(int i = 0;i < s.size();i++){
if(s[i] == ' ') continue;
cnt++;
//cout << s[i] << endl;
}
cout << cnt;
return 0;
}
//2642
#include<iostream>
//#include<cstdio>
#include<string>
//#include<vector>
//#include<deque>
//#include<cmath>
#include<algorithm>
using namespace std;
#define fst ios::sync_with_stdio(false);
#define fast cin.tie(),cout.tie();
#define ll long long
#define endl '\n'
int a[15];
int main(){
fst
fast
for(int i = 1;i <= 7;i++) cin >> a[i];
sort(a+1,a+8);
cout << a[1] << " " << a[2] << " " << a[7] - a[1] - a[2] << endl;
return 0;
}
//1680
#include<iostream>
//#include<cstdio>
#include<string>
//#include<vector>
//#include<deque>
//#include<cmath>
//#include<algorithm>
using namespace std;
#define fst ios::sync_with_stdio(false);
#define fast cin.tie(),cout.tie();
#define ll long long
#define endl '\n'
string s[20] = {"0","10","J","Q","K","A","2","Joker"};
string a,b;
int id_a = -1,id_b = -1;
int main(){
fst
fast
cin >> a >> b;
for(int i = 1;i <= 7;i++){
if(s[i] == a) id_a = i;
if(s[i] == b) id_b = i;
}
if(id_a > id_b) cout << "First" << endl;
else if(id_a < id_b) cout << "Second" << endl;
else cout << "Equal"<<endl;
return 0;
}
//1971
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<deque>
#include<cmath>
#include<algorithm>
using namespace std;
#define fst ios::sync_with_stdio(false);
#define fast cin.tie(),cout.tie();
#define ll long long
#define endl '\n'
int factors(int n,int m){
int cnt = 0;
double n1 = n;
while(int(n1 + 0.5) == n1 && n1 != 0){
n1 /= m;
if(int(n1 + 0.5) != n1 || n1 == 0) break;
//cout << n1 << endl;
cnt++;
}
return cnt;
}
int a,k;
int main(){
fst
fast
cin >> a >> k;
int ans = factors(a,k);
cout << ans;
return 0;
}
//1681
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<deque>
#include<cmath>
#include<algorithm>
using namespace std;
#define fst ios::sync_with_stdio(false);
#define fast cin.tie(),cout.tie();
#define ll long long
#define endl '\n'
deque<int> d;
int n,k;
int main(){
fst
fast
cin >> n >> k;
for(int i = 1;i <= n;i++){
d.push_back(i);
}
int now_num = 0;
while(d.size() > 1){
now_num += 1;
if(now_num == k){
d.pop_front();
now_num = 0;
continue;
}
d.push_back(d[0]);
d.pop_front();
}
cout << d[0];
return 0;
}
//2209
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<deque>
#include<cmath>
#include<algorithm>
using namespace std;
#define fst ios::sync_with_stdio(false);
#define fast cin.tie(),cout.tie();
#define ll long long
#define endl '\n'
int n;
struct student{
int id,chinese_score,maths_score,english_score,Score;
}s[305];
bool cmp(student a,student b){
if(a.Score != b.Score) return a.Score > b.Score;
else if(a.chinese_score != b.chinese_score) return a.chinese_score > b.chinese_score;
return a.id < b.id;
}
int main(){
fst
fast
cin >> n;
for(int i = 1;i <= n;i++){
cin >> s[i].chinese_score >> s[i].maths_score >> s[i].english_score;
s[i].Score = s[i].chinese_score + s[i].maths_score + s[i].english_score;
s[i].id = i;
}
sort(s + 1,s + n + 1,cmp);
for(int i = 1;i <= 5;i++){
cout << s[i].id << " " << s[i].Score << endl;
}
return 0;
}
//2643
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<deque>
#include<cmath>
#include<algorithm>
using namespace std;
#define fst ios::sync_with_stdio(false);
#define fast cin.tie(),cout.tie();
#define ll long long
#define endl '\n'
int b,n;
deque<char> d;
int main(){
fst
fast
d.push_back('A');
d.push_back('B');
d.push_back('C');
d.push_back('D');
d.push_back('E');
// for(int i = 0;i < 5;i++){
// cout << d[i] << endl;
// }
while(cin >> b){
cin >> n;
if(b == 1){
for(int i = 1;i <= n;i++){
d.push_back(d[0]);
d.pop_front();
}
}else if(b == 2){
for(int i = 1;i <= n;i++){
d.push_front(d[4]);
d.pop_back();
}
}else{
for(int i = 1;i <= n;i++){
swap(d[0],d[1]);
}
}
}
for(int i = 0;i < 5;i++) cout << d[i] << " ";
return 0;
}
//1682
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<deque>
#include<cmath>
#include<algorithm>
using namespace std;
#define fst ios::sync_with_stdio(false);
#define fast cin.tie(),cout.tie();
#define ll long long
#define endl '\n'
int n;
struct peo{
string name;
int age,id;
}p[205];
bool cmp(peo a,peo b){
if(a.age > 60 && b.age <= 60) return true;
else if(a.age <= 60 && b.age > 60) return false;
return a.id < b.id;
}
int main(){
fst
fast
cin >> n;
for(int i = 1;i <= n;i++){
cin >> p[i].name >> p[i].age >> p[i].id;
}
sort(p +1,p + n + 1,cmp);
for(int i = 1;i <= n;i++){
cout <<p[i].name << endl;
}
return 0;
}
*/
//41
/*
//枚举加强——枚举三要素:对象、范围、判定条件
//1585
#include<iostream>
//#include<cstdio>
//#include<string>
//#include<vector>
//#include<deque>
//#include<cmath>
//#include<algorithm>
using namespace std;
#define fst ios::sync_with_stdio(false);
#define fast cin.tie(),cout.tie();
#define ll long long
#define endl '\n'
int main(){
fst
fast
for(int g = 0;g <= 100 / 5;g++){
for(int m = 0;m <= 100 / 3;m++){
int x = 100 - g - m;
if(g * 5 + m * 3 + x / 3 == 100 && x >= 0 && x % 3 == 0){
cout << g << " " << m << " " << x << endl;
}
}
}
return 0;
}
//1683
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<deque>
#include<cmath>
#include<algorithm>
using namespace std;
#define fst ios::sync_with_stdio(false);
#define fast cin.tie(),cout.tie();
#define ll long long
#define endl '\n'
int f[15];
void check(int n){
f[n % 10] += 1;
n /= 10;
f[n % 10] += 1;
n /= 10;
f[n % 10] += 1;
return;
}
int main(){
fst
fast
for(int a = 123;a <= 369;a++){
for(int i = 1;i <= 14;i++) f[i] = 0;
check(a);
check(a * 2);
check(a * 3);
int flag = 1;
for(int i = 1;i <= 9;i++){
if(f[i] > 1 || f[i] == 0 || a * 2 > 999 || a * 3 > 999){
flag = 0;
break;
}
}
if(flag) cout << a << " " << a * 2 << " " << a * 3 << endl;
}
return 0;
}
//2107
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<deque>
#include<cmath>
#include<algorithm>
using namespace std;
#define fst ios::sync_with_stdio(false);
#define fast cin.tie(),cout.tie();
#define ll long long
#define endl '\n'
string s;
int main(){
fst
fast
cin >> s;
int len = s.size();
for(int i = 1;i <= len;i++){
if(len % i == 0){
int x = len / i;
string s1 = "",t = s.substr(0,i);
for(int j = 1;j <= x;j++) s1 += t;
if(s1 == s){
cout << i << endl;
break;
}
}
}
return 0;
}
//1684
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<deque>
#include<cmath>
#include<algorithm>
using namespace std;
#define fst ios::sync_with_stdio(false);
#define fast cin.tie(),cout.tie();
#define ll long long
#define endl '\n'
int n,m,cfx,zfx;
int main(){
fst
fast
cin >> n >> m;
for(int i = 0;i <= n;i++){ //注意从0开始
for(int j = 0;j <= m;j++){
for(int k = i + 1;k <= n;k++){
for(int l = j + 1;l <= m;l++){
if(k - i == l - j) zfx += 1;
else cfx += 1;
}
}
}
}
cout << zfx << " " << cfx << endl;
return 0;
}
//1507
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<deque>
#include<cmath>
#include<algorithm>
using namespace std;
#define fst ios::sync_with_stdio(false);
#define fast cin.tie(),cout.tie();
#define ll long long
#define endl '\n'
int n,m,cnt,a[5005];
int main(){
fst
fast
cin >> n >> m;
for(int i = 1;i <= n;i++) a[i] = i;
for(int i = 1;i <= n;i++){
for(int j = i + 1;j <= n;j++){
if(a[i] + a[j] > m) cnt++;
}
}
cout <<cnt << endl;
return 0;
}
//2228
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<deque>
#include<cmath>
#include<algorithm>
using namespace std;
#define fst ios::sync_with_stdio(false);
#define fast cin.tie(),cout.tie();
#define ll long long
#define endl '\n'
int mx = -2147483647,n,a[105],f = 1;
int main(){
fst
fast
cin >> n;
for(int i = 1;i <= n;i++) cin >> a[i];
sort(a + 1,a + n + 1);
for(int i = 1;i <= n;i++){
for(int j = i + 1;j <= n;j++){
for(int k = j + 1;k <= n;k++){
if(a[i] + a[j] > a[k])
mx = max(mx,a[i] + a[j] + a[k]),f = 0;
}
}
}
if(f) cout << 0;
else cout << mx;
return 0;
}
*/
//42
/*
//2656
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<deque>
#include<cmath>
#include<algorithm>
using namespace std;
#define fst ios::sync_with_stdio(false);
#define fast cin.tie(),cout.tie();
#define ll long long
#define endl '\n'
int n,a[105],sum,cnt;
int main(){
fst
fast
cin >> n;
for(int i = 1;i <= n;i++) cin >> a[i];
cin >> sum;
for(int i = 1;i <= n;i++){
for(int j = i + 1;j <= n;j++){
if(a[i] + a[j] == sum) cnt++;
}
}
cout << cnt;
return 0;
}
//2657
//元素Ai可能是和与两个加数
//错误写法:
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<deque>
#include<cmath>
#include<algorithm>
using namespace std;
#define fst ios::sync_with_stdio(false);
#define fast cin.tie(),cout.tie();
#define ll long long
#define endl '\n'
int n,a[105],cnt;
int main(){
fst
fast
cin >> n;
for(int i = 1;i <= n;i++) cin >> a[i];
sort(a + 1,a + n + 1);
for(int i = 1;i <= n;i++){
for(int j = i + 1;j <= n;j++){
for(int k = j + 1;k <= n;k++){
if(a[i] + a[j] == a[k]){
cnt++;
//cout << a[i] << "+" << a[j] << "=" << a[k] << endl;
}
}
}
}
cout << cnt;
return 0;
}
//正确写法
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<deque>
#include<cmath>
#include<algorithm>
using namespace std;
#define fst ios::sync_with_stdio(false);
#define fast cin.tie(),cout.tie();
#define ll long long
#define endl '\n'
int n,a[105],cnt,f[10005];
int main(){
cin >> n;
for(int i = 1;i <= n;i++) cin >> a[i];
for(int i = 1;i <= n;i++){
for(int j = 1;j <= n;j++){
for(int k = 1;k <= n;k++){
if(a[i] + a[j] == a[k] && i != j && i != k && j != k && f[a[k]] == 0){
f[a[k]] = 1;
cnt++;
}
}
}
}
cout << cnt;
return 0;
}
//2658
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<deque>
#include<cmath>
#include<algorithm>
using namespace std;
#define fst ios::sync_with_stdio(false);
#define fast cin.tie(),cout.tie();
#define ll long long
#define endl '\n'
int n,p[105],cnt;
int main(){
cin >> n;
for(int i = 1;i <= n;i++) cin >> p[i];
for(int l = 1;l <= n;l++){
for(int r = 1;r <= n;r++){
int sum = 0;
for(int k = l;k <= r;k++){
sum += p[k];
}
for(int k = l;k <= r;k++){
if(sum * 1.0 / (r - l + 1) == p[k]){
cnt ++;
break;
}
}
}
}
cout << cnt;
return 0;
}
//2659
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<deque>
#include<cmath>
#include<algorithm>
using namespace std;
#define fst ios::sync_with_stdio(false);
#define fast cin.tie(),cout.tie();
#define ll long long
#define endl '\n'
int n,a[1005],cnt;
bool check(int k){
if(cnt % k != 0) return false;
int sum = cnt / k,now = 0;
for(int i = 1;i <= n;i++){
now += a[i];
if(now == sum) now = 0;
if(now > sum) return false;
}
return true;
}
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> a[i];
cnt += a[i];
}
int l = 1,r = 1000,ans = -1;
while(l <= r){
int mid = (l + r) / 2;
if(check(mid)) l = mid + 1,ans = mid;
else r = mid - 1;
}
if(cnt == 0){
cout << 0;
return 0;
}
cout << n - ans << endl;
return 0;
}
//2660
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<deque>
#include<cmath>
#include<algorithm>
using namespace std;
#define fst ios::sync_with_stdio(false);
#define fast cin.tie(),cout.tie();
#define ll long long
#define endl '\n'
int n,a[15],b[15],q[15],maxa = 2147483647,maxb = 2147483647,cnt;
//数组开大防止越界
int main(){
fst
fast
cin >> n;
for(int i = 1;i <= n;i++) cin >> q[i];
for(int i = 1;i <= n;i++){
cin >> a[i];
if(a[i] != 0) maxa = min(maxa,q[i] / a[i]);
}
for(int i = 1;i <= n;i++){
cin >> b[i];
if(b[i] != 0) maxb = min(maxb,q[i] / b[i]);
}
// cout << maxa << " " << maxb << endl;
for(int i = 0;i <= maxa;i++){
for(int j = 0;j <= maxb;j++){
int f = 1;
for(int k = 1;k <= n;k++){
if(i * a[k] + j * b[k] > q[k]){
f = 0;
break;
}
}
if(f) cnt = max(cnt,i + j);
}
}
cout << cnt << endl;
return 0;
}
//2220
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<deque>
#include<cmath>
#include<algorithm>
using namespace std;
#define fst ios::sync_with_stdio(false);
#define fast cin.tie(),cout.tie();
#define ll long long
#define endl '\n'
int n,cnt;
int main(){
fst
fast
cin >> n;
for(int i = 1;i <= n;i++){
int sum = 0;
for(int j = 1;j <= i;j++){
if(i % j == 0) sum++;
}
if(sum % 2 == 0) cnt++;
}
cout << cnt << endl;
return 0;
}
*/
//2661
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<deque>
#include<cmath>
#include<algorithm>
using namespace std;
#define fst ios::sync_with_stdio(false);
#define fast cin.tie(),cout.tie();
#define ll long long
#define endl '\n'
int n,a[105],d,cnt,ans = 2e9;
int main(){
cin >> n >> d;
for(int i = 1;i <= n;i++) cin >> a[i];
for(int i = 1;i <= n;i++){
cnt = 0;
for(int j = 1;j <= n;j++){
if(a[j] < a[i] || a[i] + d < a[j]) cnt++;
}
ans = min(cnt,ans);
}
cout << ans;
return 0;
}