#include <cstdio>
#include <set>
#include<iostream>
#include<cmath>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
int n, m, t;
int mod = 1000000007;
int main()
{
int a = 5 * (100 - 32) / 9;
cout << "fahr = 100, celsius = " << a;
return 0;
}
#include <cstdio>
#include <set>
#include<iostream>
#include<cmath>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
int main()
{
int n;
cin >> n;
bool wrong = 0;
for (int ii = 0; ii < n; ii++)
{
string s;
cin >> s;
long long sum = 0;
int a[17] = { 7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2 };
for (int i = 0; i < 17; i++)
{
sum += (int)(s[i] - '0') * a[i];
}
sum %= 11;
if (sum == 0 && s[17] != '1')
{
cout << s;
cout << endl;
wrong = 1;
}
else if (sum == 1 && s[17] != '0')
{
cout << s;
cout << endl;
wrong = 1;
}
else if (sum == 2 && s[17] != 'X')
{
cout << s;
cout << endl;
wrong = 1;
}
else if (sum == 3 && s[17] != '9')
{
cout << s;
cout << endl;
wrong = 1;
}
else if (sum == 4 && s[17] != '8')
{
cout << s;
cout << endl;
wrong = 1;
}
else if (sum == 5 && s[17] != '7')
{
cout << s;
cout << endl;
wrong = 1;
}
else if (sum == 6 && s[17] != '6')
{
cout << s;
cout << endl;
wrong = 1;
}
else if (sum == 7 && s[17] != '5')
{
cout << s;
cout << endl;
wrong = 1;
}
else if (sum == 8 && s[17] != '4')
{
cout << s;
cout << endl;
wrong = 1;
}
else if (sum == 9 && s[17] != '3')
{
cout << s;
cout << endl;
wrong = 1;
}
else if (sum == 10 && s[17] != '2')
{
cout << s;
cout << endl;
wrong = 1;
}
}
if (wrong == 0)cout << "All passed";
return 0;
}
#include <cstdio>
#include <set>
#include<iostream>
#include<cmath>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
int main()
{
int n;
cin >> n;
string tmp[100005];
int num,mul;
int pan[100005];
bool noh = 1;
for (int ii = 0; ii < n; ii++)
{
int k;
cin >> k;
for (int o = 0; o < k; o++)
{
cin >> tmp[ii];
num = 0,mul=1;
for (int i = 4; i >=0; i--)
{
num += (int)(tmp[ii][i] - '0') * mul;
mul *= 10;
}
if (k > 1)
{
pan[num] = 1;
}
}
}
int m;
cin >> m;
queue<int>final;
for (int ii = 0; ii < m; ii++)
{
num = 0, mul = 1;
cin >> tmp[ii];
for (int i = 4; i >= 0; i--)
{
num += (int)(tmp[ii][i] - '0') * mul;
mul *= 10;
}
if (pan[num] == 0)
{
final.push(ii);
pan[num] = 1;
noh = 0;
}
}
while (!final.empty())
{
cout << tmp[final.front()];
final.pop();
if (final.empty())
{
cout << endl;
break;
}
cout << ' ';
}
if (noh == 1)cout << "No one is handsome";
return 0;
}
#include <cstdio>
#include <set>
#include<iostream>
#include<cmath>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
int main()
{
string s;
cin >> s;
int tot[4] = {0};
int len = s.length();
for (int i = 0; i < len; i++)
{
if (s[i] == 'g' || s[i] == 'G')tot[0]++;
if (s[i] == 'p' || s[i] == 'P')tot[1]++;
if (s[i] == 'l' || s[i] == 'L')tot[2]++;
if (s[i] == 't' || s[i] == 'T')tot[3]++;
}
int ma = 0, mi = 1000000;
for (int i = 0; i < 4; i++)
{
ma = max(ma, tot[i]);
mi = min(mi, tot[i]);
}
for (int i = 0; i < mi; i++)
{
cout << "GPLT";
}
for (int i = 0; i < 4; i++)
{
tot[i] -= mi;
}
for (int i = mi;tot[0]||tot[1]||tot[2]||tot[3]; i++)
{
if (tot[0] > 0) {
cout << 'G'; tot[0]--;
}
if (tot[1] > 0) {
cout << 'P'; tot[1]--;
}
if (tot[2] > 0) {
cout << 'L'; tot[2]--;
}
if (tot[3] > 0) {
cout << 'T'; tot[3]--;
}
}
return 0;
}
#include <cstdio>
#include <set>
#include<iostream>
#include<cmath>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
bool ip(long long x)
{
if (x == 1)return 0;
if (x == 1)return 1;
for (int i = 2; i <= (int)sqrt(x); i++)
{
if (x % i == 0)return 0;
}
return 1;
}
int main()
{
int n;
cin >> n;
long long num;
for (int i = 0; i < n; i++)
{
cin >> num;
if (ip(num))cout << "Yes\n";
else cout << "No\n";
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
char sex; double h;
for (int i = 0; i < n; i++)
{
cin >> sex>>h;
if (sex == 'M')cout << fixed << setprecision(2) << h * 1.000 / 1.09 << endl;
else cout<< fixed << setprecision(2) << h * 1.09 << endl;
}
return 0;
}
#include <cstdio>
#include <set>
#include<iostream>
#include<cmath>
#include <queue>
#include <utility>
#include<string>
#include <algorithm>
#include<iomanip>
#include <map>
#include<stack>
using namespace std;
#define mode 1000000007
#define ll long long
#define maxn 1000001
#define N 1000005
int main()
{
int n;
cin >> n;
int cnt = 0; int ans = 0;int start=0;
ll tmp;
int pre;
for (int i = 2; i <= sqrt(n); i++)
{
if (n % i == 0)
{
pre = i;
cnt = 1;
tmp = n / i;
for (int j = i+1; j <= n; j++)
{
if (j > tmp)
{
if (cnt > ans)
{
ans = cnt, start=i;
}
break;
}
if (tmp % j != 0)
{
if (cnt > ans)
{
ans = cnt, start = i;
}
break;
}
cnt++;
tmp /= j;
}
}
}
if (ans == 0)
{
cout << '1' << endl;
cout << n;
return 0;
}
cout << ans << endl;
for (int i = start; i < start + ans; i++)
{
cout << i;
if (i < start + ans - 1)cout << '*';
}
return 0;
}
#include <cstdio>
#include <set>
#include<iostream>
#include<cmath>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
int main()
{
int y, n;
cin >> y >> n;
int ans = 0;
for (int i=y; 1;ans++,i++)
{
int num[10] = { 0 }, tmp = i, cnt = 0;
for (int j = 0; j < 4; j++)
{
if (num[tmp % 10] == 0)
{
num[tmp % 10] = 1;
cnt++;
}
tmp /= 10;
}
if (cnt == n)break;
}
cout << ans << ' ';
if (y + ans < 10)cout << "000";
else if (y + ans < 100)cout << "00";
else if (y + ans < 1000)cout << '0';
cout << y + ans;
return 0;
}
#include <cstdio>
#include <set>
#include<iostream>
#include<cmath>
#include <queue>
#include <utility>
#include<string>
#include <algorithm>
#include<iomanip>
#include <map>
#include<stack>
using namespace std;
#define mode 1000000007
#define ll long long
#define maxn 1000001
#define N 1000005
int n, m,fa[505];
struct edge
{
int u, v;
}e[5005];
int find(int x)
{
while (fa[x] != x)x = fa[x];
return x;
}
void merge(int x, int y)
{
int a = find(x), b = find(y);
if (a != b)fa[a] = b;
}
int cnt1=0, cnt2=0, vis[505],k;
int main()
{
cin >> n >> m;
for (int i = 0; i < n; i++)fa[i] = i;
for (int ii = 1; ii <= m; ii++)
{
cin >> e[ii].u >> e[ii].v;
merge(e[ii].u, e[ii].v);
}
for (int i = 0; i < n; i++)
{
if (fa[i] == i)cnt1++;
}
cin >> k;
for (int ii = 0; ii < k; ii++)
{
cnt2 = 0;
int num;cin >> num;
vis[num] = 1;
for (int i = 0; i < n; i++)fa[i] = i;
for (int i = 1; i <= m; i++)
{
if (vis[e[i].u] == 1 || vis[e[i].v] == 1)continue;
merge(e[i].u, e[i].v);
}
for (int i = 0; i < n; i++)
{
if (fa[i] == i)cnt2++;
}
if (cnt2 == cnt1 || cnt2 == cnt1 + 1)printf("City %d is lost.\n", num);
else printf("Red Alert: City %d is lost!\n", num);
cnt1 = cnt2;
}
if (k == n)printf("Game Over.");
return 0;
}
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
const int max_n = 1000;
const int max_m = 1000;
double relation[max_n][max_n];
bool sex[max_n];
int input[max_n];
int str2int(string str) {
int len = str.size();
int b = 1, i = 0;
if (str[0] == '-') {
b = 0;
i++;
}
int ret = 0;
while (i < len) {
ret = ret * 10 + (str[i] - '0');
i++;
}
sex[ret] = b;
return ret;
}
void str2char(string str, char* ch) {
int len = str.size();
for (int i = 0; i < len; i++) {
ch[i] = str[i];
}
ch[len] = '\0';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m, k;
cin >> n >> m;
string s;
for (int i = 0; i < m; i++) {
cin >> k;
for (int j = 0; j < k; j++) {
cin >> s;
input[j] = str2int(s);
}
//统计亲密度
for (int j = 0; j < k; j++) {
for (int z = j + 1; z < k; z++) {
relation[input[j]][input[z]] += 1.0 / k;
relation[input[z]][input[j]] += 1.0 / k;
}
}
}
string p1, p2;
int ip1, ip2;
vector<pair<double, int>>ans1, ans2;//最大亲密度
cin >> p1 >> p2;
ip1 = str2int(p1); ip2 = str2int(p2);
double t = relation[ip1][ip2];//情侣亲密度
ans1.push_back({ t,ip2 }); ans2.push_back({ t,ip1 });
//寻找最大亲密度
for (int i = 0; i < n; i++) {
if (i != ip2 && sex[i] ^ sex[ip1]) {
if (relation[ip1][i] - ans1[0].first > 1e-6) {
ans1.clear();
ans1.push_back({ relation[ip1][i],i });
}
else if (fabs(ans1[0].first - relation[ip1][i]) < 1e-6) {
ans1.push_back({ relation[ip1][i],i });
}
}
if (i != ip1 && sex[i] ^ sex[ip2]) {
if (relation[ip2][i] - ans2[0].first > 1e-6) {
ans2.clear();
ans2.push_back({ relation[ip2][i],i });
}
else if (fabs(ans2[0].first - relation[ip2][i]) < 1e-6) {
ans2.push_back({ relation[ip2][i],i });
}
}
}
char format[1024];//输出格式
string temp;
if (sex[ip1]) temp = "%d -%d\n";
else temp = "-%d %d\n";
str2char(temp, format);
if (ans1[0].second == ip2 && ans2[0].second == ip1) {
printf(format, ip1, ip2);
return 0;
}
{
sort(ans1.begin(), ans1.end(), [](pair<double, int>p1, pair<double, int>p2) {
return p1.second < p2.second;
});
int len = ans1.size();
for (int i = 0; i < len; i++) {
printf(format, ip1, ans1[i].second);
}
}
if (sex[ip2]) temp = "%d -%d\n";
else temp = "-%d %d\n";
str2char(temp, format);
{
sort(ans2.begin(), ans2.end(), [](pair<double, int>p1, pair<double, int>p2) {
return p1.second < p2.second;
});
int len = ans2.size();
for (int i = 0; i < len; i++) {
printf(format, ip2, ans2[i].second);
}
}
return 0;
}
#include <cstdio>
#include <set>
#include<iostream>
#include<cmath>
#include <queue>
#include <utility>
#include<string>
#include <algorithm>
#include<iomanip>
#include <map>
#include<stack>
using namespace std;
#define mode 1000000007
#define ll long long
#define maxn 1000001
#define N 1000005
const ll mx = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
int n, m, k;
queue<int> tui;
int tmp;
int num[50000] = { 0 };
int pre[10001];
int sz = 0,cnt=0;
stack<int> he;
queue<int> ans[10001];
int main()
{
for (int i = 0; i < 1001; i++)
{
pre[i] = 100001;
}
cin >> n>>m>>k;
for (int ii = 0; ii < n; ii++)
{
cin >> tmp;
tui.push(tmp);
}
while (!he.empty()||!tui.empty())
{
if (!he.empty() && he.top() <= pre[cnt])//盒子满足
{
ans[cnt].push(he.top()); pre[cnt]=he.top(); he.pop();
if (ans[cnt].size() == (unsigned int)k)cnt++;
}
else if (he.empty() && !tui.empty() && tui.front() <= pre[cnt])
{//盒子空,推送器满足;
ans[cnt].push(tui.front());pre[cnt]=tui.front(); tui.pop();
if (ans[cnt].size() == (unsigned int)k)cnt++;
}
else if (!he.empty() && he.top() > pre[cnt]&&!tui.empty()&&
tui.front()<=pre[cnt])//盒子大,推送器满足
{
ans[cnt].push(tui.front()); pre[cnt] = tui.front();
if (ans[cnt].size() == (unsigned int)k)cnt++;
tui.pop();
}
else if (he.size() != (unsigned int)m && !tui.empty())
{
he.push(tui.front()); tui.pop();
}
else if (he.size()== (unsigned int)m||tui.empty())
{
cnt++;
}
}
for (int i = 0; i <= cnt; i++)
{
cout << ans[i].front(); ans[i].pop();
while (!ans[i].empty())
{
cout <<' '<< ans[i].front();
ans[i].pop();
}
cout << endl;
}
return 0;
}
#include <cstdio>
#include <set>
#include<iostream>
#include<cmath>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
vector<int>dt[100005];
int main()
{
int n, m,k,tmp;
cin >> n >> m;
for (int ii = 1; ii <= n; ii++)
{
cin >> k;
for (int i = 0; i < k; i++)
{
cin >> tmp;
dt[ii].push_back(tmp);
}
}
int now = 1,zhong,opr;
int dang[1005];
for (int ii = 0; ii < m; ii++)
{
cin >> zhong>>opr;
if (zhong == 0)
{
now = dt[now][opr - 1];
}
if (zhong == 1)
{
dang[opr] = now;
cout << now << endl;
}
if (zhong == 2)
{
now = dang[opr];
}
}
cout << now;
return 0;
}