第十届山东省ACM程序设计竞赛(补题)
A:只和日有关系,不用管年和月;
//#include<bits/stdc++.h>
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<stack>
#include<queue> //stack的头文件
using namespace std ;
typedef long long ll;
#define MAXN 501
#define INF 0x3f3f3f3f
#define MALL (BiTnode *)malloc(sizeof(BiTnode));
string s[5] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday"};
int main()
{
int t;
cin >> t;
while(t--)
{
int y1, m1, d1, y2, m2, d2;
string sh;
scanf("%d %d %d", &y1, &m1, &d1);
cin >> sh;
scanf("%d %d %d", &y2, &m2, &d2);
int x, sum=0;
for(int i=0; i<5; ++i)
if(sh == s[i])
x = i;
if(m2 >= m1)
{
sum+=(30-d1+d2);
while(sum--)
{
x++;
if(x == 5)
x=0;
}
}
else
{
sum+=(30-d2+d1);
while(sum--)
{
x--;
if(x == -1)
x=4;
}
}
// cout << x << ' ';
cout << s[x] << '\n';
}
return 0;
}
C: 首先想到的是先把前n-1的算出来,然后在此基础上在进行一遍,求个最优,错了n次后发现,没用long long而且前n-1次可能对最后一次有负影响,所以,先对前面的取最优就可以了
//#include<bits/stdc++.h>
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<stack>
#include<queue> //stack的头文件
using namespace std ;
typedef long long ll;
#define MAXN 1000005
#define INF 0x3f3f3f3f
#define MALL (BiTnode *)malloc(sizeof(BiTnode));
int main()
{
int t;
cin >> t;
while(t--)
{
ll n, k, x=0, y=0;
char ch[MAXN];
scanf("%lld %lld %s", &n, &k, ch);
ll ans=0, tem;
if(k!=1)
{
for(int i=0; i<n; ++i)
{
if(ch[i] == 'U') y++;
if(ch[i] == 'D') y--;
if(ch[i] == 'L') x--;
if(ch[i] == 'R') x++;
tem = abs(x) + abs(y);
if(tem > ans) ans = tem;
}
x = x*(k-1);
y = y*(k-1);
}
for(int i=0; i<n; ++i)
{
if(ch[i] == 'U') y++;
if(ch[i] == 'D') y--;
if(ch[i] == 'L') x--;
if(ch[i] == 'R') x++;
tem = abs(x) + abs(y);
if(tem > ans) ans = tem;
}
cout << ans << '\n';
}
return 0;
}
D:只要剩下k-1条边就可以了,,,因为题目保证是连通图了,而且最优的连通图只需要n-1条边,,所以直接算出要去除的边数,然后mod 顶点数k,看有多少个循环,最后判断一下:
#include<stdio.h>
#include<iostream>
#include<map>
#include<algorithm>
#include<cstring>
#include<string.h>
#include<math.h>
using namespace std;
typedef long long ll;
#define MAXN 100005
#define INF 0x3f3f3f3f//将近int类型最大数的一半,而且乘2不会爆int
char ch[MAXN];
int main()
{
int t;
cin >> t;
while (t--)
{
int k, n, m, x, y;
scanf("%d %s", &k, ch);
scanf("%d %d", &n, &m);
for (int i = 0; i < m; ++i)
scanf("%d %d", &x, &y);
int ans = (m - n + 1)%k;
if (ch[ans] == '1')
cout << 2 << '\n';
else
cout << 1 << '\n';
}
return 0;
}
F:(别问我为什么,改成long long 就绿了)
//#include<bits/stdc++.h>
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<stack>
#include<queue> //stack的头文件
using namespace std ;
typedef long long ll;
#define MAXN 100005
#define INF 0x3f3f3f3f
#define MALL (BiTnode *)malloc(sizeof(BiTnode));
ll a[MAXN];
int main()
{
int t;
scanf("%d", &t);
while(t--)
{
ll n;
scanf("%lld", &n);
ll ans=0, sum=0, tem;
for(int i=0; i<n; ++i)
{
scanf("%d", &a[i]);
ans+=a[i];
}
tem = ans/n;
for(int i=0; i<n; ++i)
{
if(a[i] > tem)
sum += (a[i] - tem);
}
cout << sum << '\n';
}
return 0;
}
M:
//#include<bits/stdc++.h>
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<stack>
#include<queue> //stack的头文件
using namespace std ;
typedef long long ll;
#define MAXN 1000005
#define INF 0x3f3f3f3f
#define MALL (BiTnode *)malloc(sizeof(BiTnode));
int main()
{
int t;
scanf("%d", &t);
while(t--)
{
int n, k;
scanf("%d %d", &n, &k);
while(k-- && n>1)
{
if(n%2)
n = n/2+1;
else
n = n/2;
}
cout << n << '\n';
}
return 0;
}
其它题,,,,~~~~~BZ比较菜,,,,
660


&spm=1001.2101.3001.11974&articleId=90180977&d=1&t=3&u=8f8858686c84445ca29f89e60094388f)

被折叠的 条评论
为什么被折叠?



