BestCoder 1st Anniversary T_T

1001 Souvenir

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
* 2015年7月25日 下午7:07:41
* PrjName:0725-01
* @ Semprathlon
*/
public class Main {

public static void main(String[] args) {
// TODO Auto-generated method stub
InputReader in=new InputReader(System.in);
PrintWriter out=new PrintWriter(System.out);
int T=in.nextInt();
while(T-->0){
int n=in.nextInt();
int m=in.nextInt();
int p=in.nextInt();
int q=in.nextInt();
int ans=0,has=0;
if (m*p>q)
ans+=n/m*q;
else ans+=n/m*m*p;
ans+=n%m*p;
if ((n+m)/m*q<ans) ans=(n+m)/m*q;
out.println(ans);
}
out.flush();
out.close();
}

}

1002 Hidden String

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
用Trie做查询时,往死胡同里钻而且根本停不下来,啊啊啊啊……

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <cstdio>
#include <cstring>
char s[200], con[] = "anniversary";

int main()
{
int T;
scanf("%d", &T);
while(T--)
{
scanf("%s", s);
int len = strlen(s);
bool flag = false;
for(int i = 0; i <= 8; i++)
{
for(int j = i + 1; j <= 9; j++)
{
int k = 0;
while(k < len && strncmp(con, s + k, i + 1) != 0)
k ++;
if(k == len)
continue;
k += i + 1;
while(k < len && strncmp(con + i + 1, s + k, j - i) != 0)
k ++;
if(k == len)
continue;
k += j - i;
while(k < len && strncmp(con + j + 1, s + k, 10 - j) != 0)
k ++;
if(k != len)
{
flag = true;
break;
}
}
}
if(flag)
puts("YES");
else
puts("NO");
}
}

这里的枚举倒是简洁得出奇。

1003 Sequence

Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
下意识地做了贪心,果然被hack

Author

Semprathlon / Simfae Dean

Posted on

07/26/2015

Updated on

07/19/2023

Licensed under

Comments