比赛链接:【LGR-196-Div.4】洛谷入门赛 #26 - 比赛详情 - 洛谷
A.相识于 2016
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
n=(n-2016)*12+(m-8+1);
cout<<n;
return 0;
}
B.游戏与共同语言
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n1,n2,n3,m1,m2,m3;
cin>>n1>>n2>>n3>>m1>>m2>>m3;
if(n1>m1)
{
cout<<"A";
return 0;
}
else if(n1<m1)
{
cout<<"B";
return 0;
}
else
{
if(n2>m2)
{
cout<<"A";
return 0;
}
else if(n2<m2)
{
cout<<"B";
return 0;
}
else
{
if(n3>m3)
{
cout<<"B";
return 0;
}
else if(n3<m3)
{
cout<<"A";
return 0;
}
}
}
}
C.皆与生物有缘
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,i=0,j=0,m,k;
cin>>n;
k=n;
while(k--)
{
cin>>m;
i+=m;
}
while(n--)
{
cin>>m;
j+=m;
}
n=(i+j)%2+(i+j)/2;
cout<<n;
return 0;
}
D. 两座城市的 543 千米
#include <iostream>
#include <vector>
using namespace std;
int main() {
int N, M, a, b,c;
cin >> N >> M >> a >> b;
int count = 0;
while (M--)
{
int l;
cin >> l;
int foundA = -1;
int foundB = -1;
for (int i = 0; i < l; ++i)
{
cin >> c;
if(c==a&&foundA==-1)
{
foundA=i;
}
if(c==b)
{
foundB=i;
}
}
if(foundA!=-1&&foundB!=-1&&foundA<foundB)
{
count++;
}
}
cout << count << endl;
return 0;
}
E.于抑郁中支持
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, t;
cin >> n >> t;
unordered_set<int> events;
int mod = 1;
for (int i = 0; i < t; ++i) {
mod *= 10;
}
for (int i = 0; i < n; ++i) {
int a;
cin >> a;
int k = a % mod;
events.insert(k);
}
cout << events.size() << endl;
return 0;
}
F.蓝色的网易云
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, t, m;
cin >> n >> t;
int ssr[1000][n];
map<int, int> num;
for (int i = 1;i <= n;i++)
{
cin >> m;
int o = num[m];
ssr[m][o] = i;
num[m]++;
}
for (int i = 1;i <= n / t;i++)
{
for (int j = 1;j <= t;j++)
{
cout << ssr[j][i - 1] << endl;
}
}
return 0;
}
G.因友情而终结
#include <bits/stdc++.h>
using namespace std;
#define MAX_LENGTH 1000010
int solve(char *S) {
int n = strlen(S);
int operations = 0;
for (int i = 0; i <= n - 6; ++i) {
if (strncmp(S + i, "friend", 6) == 0) {
strncpy(S + i + 5, "love", 4);
++operations;
}
}
return operations;
}
int main() {
char S[MAX_LENGTH];
fgets(S, MAX_LENGTH, stdin);
S[strcspn(S, "\n")] = '\0';
cout<<solve(S);
return 0;
}