-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path544.cpp
More file actions
114 lines (99 loc) · 2.91 KB
/
544.cpp
File metadata and controls
114 lines (99 loc) · 2.91 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include <stdio.h>
#include <string>
using namespace std;
class ElectionFraudDiv2
{
public:
string IsFraudulent(int* percentages, int num);
};
int total = 10000;
string ElectionFraudDiv2::IsFraudulent(int* p, int num)
{
int lower = 0 ;
int higher = 0;
for ( int i = 0 ; i< num ; i++)
{
int low = ((double)p[i] - 0.5) * 100;
int high = ((double)p[i] + 0.4) * 100;
lower += low;
higher += high;
}
if ( total >= lower && total <= higher )
return "NO";
else
return "YES";
}
class AkariDaisukiDiv2
{
public:
int countTuples(string S);
};
int AkariDaisukiDiv2::countTuples(string s)
{
int res = 0;
for ( int i = 1; i <= ( s.length() - 3 ) / 2 ; i++ ){
for ( int j = 1; j <= s.length() - 2 ; j++ ){
for ( int k = j + i + 1; k <= s.length() - i - 1 ; k++ ){
if ( s.substr(j, i) == s.substr(k, i) ){
printf("%s, %s\n", s.substr(j,i).c_str(), s.substr(k,i).c_str());
res++;
}
}
}
}
return res;
}
#include <vector>
class AntsMeet{
public:
int countAnts(vector <int> x, vector <int> y, string direction);
};
int a[50];
int AntsMeet::countAnts(vector <int> x, vector <int> y, string direction)
{
memset(a, 0, 50);
for ( int i = 0 ; i < x.size(); i++){
for ( int j = i; j < x.size();j++){
if ( a[j] != 0 )
continue;
if ( x[i] == x[j] ){
if ( y[i] < y[j] && direction[i] == 'N' && direction[j] == 'S'){
a[i] = 1;
a[j] = 1;
break;
} else if ( y[i] < y[j] && direction[i] == 'S' && direction[j] == 'N') {
a[i] = 1;
a[j] = 1;
break;
}
continue;
}
if ( y[i] == y[j] ){
if ( x[i] < x[j] && direction[i] == 'E' && direction[j] == 'W'){
a[i] = 1;
a[j] = 1;
break;
} else if ( x[i] < x[j] && direction[i] == 'W' && direction[j] == 'E') {
a[i] = 1;
a[j] = 1;
break;
}
continue;
}
//if ( abs(x[i]-x[j]) == abs(y[i] - y[j]){
// if ( x[i] < x[j] && direct
//}
}
}
}
int main()
{
AkariDaisukiDiv2 as;
int result = as.countTuples("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
printf("result is %d\n", result);
/*int input[8] = {12, 12, 12, 12, 12, 12, 12, 12};
ElectionFraudDiv2 ef;
string result = ef.IsFraudulent(input, 8);
printf("result is %s\n", result.c_str());*/
return 0;
}