Skip to content

Commit 9481609

Browse files
committed
first commit
0 parents  commit 9481609

File tree

1,289 files changed

+1362966
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,289 files changed

+1362966
-0
lines changed

cf/107/WinOrFreeze.cpp

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#include <iostream>
2+
#include <cmath>
3+
#define MAXN 3200000
4+
using namespace std;
5+
long long int q;
6+
7+
int prime[MAXN];
8+
int dp[MAXN];
9+
void Prime(){
10+
int i, j;
11+
for (i=0; i<MAXN; i++) prime[i] = 1;
12+
prime[0] = prime[1] = 0;
13+
for (i=2; i<MAXN; i++)
14+
{
15+
if (!prime[i]) continue;
16+
for (j=i*2; j<MAXN; j+=i) prime[j] = 0;
17+
}
18+
}
19+
long long int first_move = -1;
20+
21+
int get_v(long long int value){
22+
if(value<MAXN){
23+
if(dp[value]!=-1){
24+
return dp[value];
25+
}
26+
if(prime[value]==1){
27+
dp[value]=1;
28+
return 1;
29+
}
30+
}
31+
int b = (int)sqrt(value)+1;
32+
int ok=0;
33+
for(int i=2; i<=b; i++){
34+
if(value%i==0){
35+
ok=1;
36+
int t = get_v(i);
37+
int t2 = get_v(value/i);
38+
if(t==0 || t2==0){
39+
if(value<MAXN)dp[value] = 1;
40+
if(first_move==-1){
41+
if(t==0){
42+
first_move = i;
43+
//cout<<"first movie is i "<<i<<endl;
44+
}
45+
if(t2==0){
46+
//cout<<"first movie is value/ i "<<value/i<<endl;
47+
first_move = value/i;
48+
}
49+
}
50+
return 1;
51+
}
52+
}
53+
}
54+
if(ok==0){
55+
return 1;
56+
}
57+
if(value<MAXN)
58+
dp[value]=0;
59+
return 0;
60+
}
61+
62+
63+
int main(){
64+
for(int i=0; i<MAXN;i++){
65+
dp[i]=-1;
66+
}
67+
cin>>q;
68+
Prime();
69+
prime[1]=1;
70+
int ans = get_v(q);
71+
if(ans==1){
72+
cout<<1<<endl;
73+
if(first_move!=-1){
74+
cout<<first_move<<endl;
75+
}else{
76+
cout<<0<<endl;
77+
}
78+
}
79+
else{
80+
cout<<2<<endl;
81+
}
82+
return 0;
83+
}

cf/107/a.out

14.1 KB
Binary file not shown.

cf/107/phonenumber.cpp

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#include <iostream>
2+
#include <stdio.h>
3+
#include <string>
4+
#define MAX_SIZE 400
5+
using namespace std;
6+
7+
int n;
8+
int n_phonenumber;
9+
string friends[MAX_SIZE];
10+
string phone_number;
11+
12+
int girls[MAX_SIZE];
13+
int pizza[MAX_SIZE];
14+
int taxi[MAX_SIZE];
15+
16+
int judge(string phone){
17+
string t = "";
18+
for(int i=0; i<phone.size();i++){
19+
if(phone[i]<='9' && phone[i]>='0'){
20+
t+=phone[i];
21+
}
22+
}
23+
if(t.size()==6){
24+
int eq = 1;
25+
for(int i=1; i<6; i++){
26+
if(t[i]!=t[i-1]){
27+
eq = 0;
28+
break;
29+
}
30+
}
31+
if(eq==1){
32+
return 1;
33+
}
34+
35+
int sm = 1;
36+
for(int i=1; i<6; i++){
37+
if(t[i]<t[i-1]){
38+
continue;
39+
}else{
40+
sm = 0;
41+
}
42+
}
43+
if(sm==1){
44+
return 2;
45+
}
46+
}
47+
return 3;
48+
}
49+
50+
51+
int main(){
52+
for(int i=0; i<MAX_SIZE; i++){
53+
taxi[i]=0;
54+
pizza[i]=0;
55+
girls[i]=0;
56+
}
57+
cin>>n;
58+
int max_taxi=-1, max_girl=-1, max_pizza = -1;
59+
for(int i=0; i<n; i++){
60+
cin>>n_phonenumber>>friends[i];
61+
for(int j = 0; j<n_phonenumber; j++){
62+
cin>>phone_number;
63+
int t = judge(phone_number);
64+
if(t==1){
65+
taxi[i]++;
66+
}else if(t==2){
67+
pizza[i]++;
68+
}else{
69+
girls[i]++;
70+
}
71+
}
72+
if(taxi[i]>max_taxi){
73+
max_taxi = taxi[i];
74+
}
75+
if(pizza[i]> max_pizza){
76+
max_pizza = pizza[i];
77+
}
78+
if(girls[i] > max_girl){
79+
max_girl = girls[i];
80+
}
81+
}
82+
int there_are = 0;
83+
cout<<"If you want to call a taxi, you should call:";
84+
for(int i=0; i<n; i++){
85+
if(taxi[i]==max_taxi){
86+
if(there_are){
87+
cout<<",";
88+
}
89+
there_are = 1;
90+
cout<<" "<<friends[i];
91+
}
92+
}cout<<"."<<endl;
93+
94+
there_are = 0;
95+
cout<<"If you want to order a pizza, you should call:";
96+
for(int i=0; i<n; i++){
97+
if(pizza[i]==max_pizza){
98+
if(there_are){
99+
cout<<",";
100+
}
101+
there_are = 1;
102+
cout<<" "<<friends[i];
103+
}
104+
}cout<<"."<<endl;
105+
106+
there_are = 0;
107+
cout<<"If you want to go to a cafe with a wonderful girl, you should call:";
108+
for(int i=0; i<n; i++){
109+
if(girls[i]==max_girl){
110+
if(there_are){
111+
cout<<",";
112+
}
113+
there_are = 1;
114+
cout<<" "<<friends[i];
115+
}
116+
}cout<<"."<<endl;
117+
return 0;
118+
}

cf/107/softdrink.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <iostream>
2+
using namespace std;
3+
int min(int a,int b){
4+
return a<b?a:b;
5+
}
6+
7+
int main(){
8+
int n,k,l,c,d,p,nl,np;
9+
cin>>n>>k>>l>>c>>d>>p>>nl>>np;
10+
int drink = k*l/nl;
11+
int lime = c*d;
12+
int salt = p/np;
13+
int toast = drink;
14+
toast = min(toast, lime);
15+
toast = min(toast, salt);
16+
cout<<toast/n<<endl;
17+
return 0;
18+
}
19+

cf/108/Marks.cpp

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#include <iostream>
2+
3+
#define MAX_SIZE 200
4+
using namespace std;
5+
int n,m;
6+
int data[MAX_SIZE][MAX_SIZE];
7+
8+
int get_max(int sub){
9+
int t_max = -99999999;
10+
for(int i=0; i<n; i++){
11+
if(data[i][sub]>t_max){
12+
t_max = data[i][sub];
13+
}
14+
}
15+
return t_max;
16+
}
17+
18+
19+
void work(){
20+
int stu=0;
21+
for(int i=0; i<n; i++){
22+
for(int j=0; j<m; j++){
23+
//cout<<j<<" "<<get_max(j)<<endl;
24+
if(get_max(j)==data[i][j]){
25+
stu+=1;
26+
break;
27+
}
28+
}
29+
}
30+
cout<<stu<<endl;
31+
32+
}
33+
34+
35+
int main(){
36+
cin>>n>>m;
37+
for(int i=0; i<n; i++){
38+
for(int j=0; j<m ;j++){
39+
char c;
40+
//scanf("%c",&c);
41+
cin>>c;
42+
data[i][j] = c-'0';
43+
//cout<<data[i][j];
44+
}
45+
//cout<<endl;
46+
}
47+
work();
48+
49+
50+
51+
return 0;
52+
}
53+

cf/108/PocketBook.cpp

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include <iostream>
2+
3+
#define MAX_SIZE 200
4+
using namespace std;
5+
6+
char data[MAX_SIZE][MAX_SIZE];
7+
int n,m;
8+
void work(){
9+
long long int sum=1;
10+
for(int j=0; j<m; j++){
11+
int tmp[MAX_SIZE];
12+
for(int k =0; k<MAX_SIZE; k++)tmp[k]=0;
13+
int num=0;
14+
for(int i=0; i<n; i++){
15+
if(tmp[data[i][j] -'A']==0){
16+
tmp[data[i][j] - 'A']=1;
17+
num++;
18+
}else{
19+
continue;
20+
}
21+
}
22+
sum = sum*num % 1000000007;
23+
}
24+
cout<<sum<<endl;
25+
}
26+
27+
28+
int main(){
29+
cin>>n>>m;
30+
for(int i=0; i<n; i++){
31+
for(int j=0; j<m ;j++){
32+
char c;
33+
cin>>c;
34+
data[i][j] = c;
35+
}
36+
}
37+
work();
38+
39+
40+
41+
return 0;
42+
}
43+

cf/108/Steps.cpp

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#include <iostream>
2+
3+
#define MAX_SIZE 20000
4+
#define INF 99999999999
5+
using namespace std;
6+
long long int n,m,k;
7+
long long int init_x, init_y;
8+
9+
long long int data[MAX_SIZE][2];
10+
11+
void work(){
12+
long long int steps = 0;
13+
long long int cur_x=init_x, cur_y=init_y;
14+
long long int t1,t2,t;
15+
for(int i=0; i<k; i++){
16+
t1 = t2 = INF;
17+
long long int d_x = data[i][0];
18+
long long int d_y = data[i][1];
19+
if(d_x==0 && d_y!=0){
20+
if(d_y>0){
21+
t2 = (m-cur_y)/d_y;
22+
}else{
23+
t2 = (1-cur_y)/d_y;
24+
}
25+
}else if(d_x!=0 && d_y==0){
26+
if(d_x>0){
27+
t1 = (n-cur_x)/d_x;
28+
}else{
29+
t1 = (1-cur_x)/d_x;
30+
}
31+
}else if(d_x>0&&d_y>0){
32+
t1 = (n-cur_x)/d_x;
33+
t2 = (m-cur_y)/d_y;
34+
}
35+
else if(d_x>0&&d_y<0){
36+
t1 = (n-cur_x)/d_x;
37+
t2 = (1-cur_y)/d_y;
38+
}
39+
else if(d_x<0&&d_y>0){
40+
t1 = (1-cur_x)/d_x;
41+
t2 = (m-cur_y)/d_y;
42+
}
43+
else if(d_x<0&&d_y<0){
44+
t1 = (1-cur_x)/d_x;
45+
t2 = (1-cur_y)/d_y;
46+
}
47+
48+
t = min(t1,t2);
49+
steps+=t;
50+
cur_x = cur_x+t*d_x;
51+
cur_y = cur_y+t*d_y;
52+
}
53+
cout<<steps<<endl;
54+
}
55+
56+
57+
int main(){
58+
cin>>n>>m;
59+
cin>>init_x>>init_y;
60+
cin>>k;
61+
for(int i=0; i<k; i++){
62+
cin>>data[i][0]>>data[i][1];
63+
}
64+
work();
65+
66+
return 0;
67+
}
68+

cf/108/a.out

9.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)