题目链接:
hdu5054 Alice and Bob
Alice and Bob
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 216 Accepted Submission(s): 166
corner of the Square, Alice in the upper right corner of the the Square. Bob regards the lower left corner as the origin of coordinates, rightward for positive direction of axis X, upward for positive direction of axis Y. Alice regards the upper right corner
as the origin of coordinates, leftward for positive direction of axis X, downward for positive direction of axis Y. Assuming that Square is a rectangular, length and width size is N * M. As shown in the figure:

Bob and Alice with their own definition of the coordinate system respectively, went to the coordinate point (x, y). Can they meet with each other ?
Note: Bob and Alice before reaching its destination, can not see each other because of some factors (such as buildings, time poor).
10 10 5 5
10 10 6 6
YES
NO
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<queue>
#define eps 1e-9
#define ll long long
#define INF 0x3f3f3f3f
using namespace std; int main()
{
int x,y,n,m;
while(scanf("%d%d%d%d",&n,&m,&x,&y)!=EOF)
{
if(2*x==n&&2*y==m)
printf("YES\n");
else
printf("NO\n");
}
}
hdu 5055 Bob and math problem
Bob and math problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 643 Accepted Submission(s): 245
There are N Digits, each digit is between 0 and 9. You need to use this N Digits to constitute an Integer.
This Integer needs to satisfy the following conditions:
- 1. must be an odd Integer.
- 2. there is no leading zero.
- 3. find the biggest one which is satisfied 1, 2.
Example:
There are three Digits: 0, 1, 3. It can constitute six number of Integers. Only "301", "103" is legal, while "130", "310", "013", "031" is illegal. The biggest one of odd Integer is "301".
Each case starts with a line containing an integer N ( 1 <= N <= 100 ).
The second line contains N Digits _1, a_2, a_3, \cdots, a_n. ( 0 \leqwhich indicate the digit $a a_i \leq 9)$.
3
0 1 3
3
5 4 2
3
2 4 6
301
425
-1
代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<queue>
#define eps 1e-9
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int maxn=100+10;
int a[maxn],odd[maxn];
char str[maxn];
int n; int main()
{
int ans,pd;
while(scanf("%d",&n)!=EOF)
{
memset(str,0,sizeof(str));
int cnt=0,first=0;
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
if(a[i]%2)
odd[++cnt]=a[i];
}
sort(odd+1,odd+1+cnt);
sort(a+1,a+1+n);
int ly=n-1;
if(cnt==0)
puts("-1");
else
{
str[ly]=odd[1]+'0';
ly--;
for(int i=1;i<=n;i++)
{
if(a[i]==odd[1]&&!first)
{
first=1;
continue;
}
else
{
str[ly]=a[i]+'0';
ly--;
}
}
if(str[0]=='0')
puts("-1");
else
{
for(int i=0;i<=n-1;i++)
printf("%c",str[i]);
printf("\n");
}
}
}
return 0;
}
Boring count
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 451 Accepted Submission(s): 169
For each case, the first line contains a string which only consist of lowercase letters. The second line contains an integer K.
[Technical Specification]
1<=T<= 100
1 <= the length of S <= 100000
1 <= K <= 100000
3
abc
1
abcabc
1
abcabc
2
6
15
21
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<queue>
#define eps 1e-9
#define ll long long
#define INF 0x3f3f3f3f
using namespace std; const int maxn=100000+10;
char str[maxn];
int cnt[28]; int main()
{
ll ans;
int t,st,k,ly;
scanf("%d",&t);
while(t--)
{
memset(cnt,0,sizeof(cnt));
st=ans=0;
scanf("%s%d",str,&k);
for(int i=0;str[i]!='\0';i++)
{
ly=str[i]-'a';
cnt[ly]++;
if(cnt[ly]>k)
{
while(str[st]!=str[i])
{
cnt[str[st]-'a']--;
st++;
}
cnt[ly]--;
st++;
}
ans+=i-st+1;
}
printf("%I64d\n",ans);
}
return 0;
}