-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem42.cpp
More file actions
46 lines (42 loc) · 766 Bytes
/
Problem42.cpp
File metadata and controls
46 lines (42 loc) · 766 Bytes
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
//162
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ll arr[100000];
int index = 0;
ll val =1;
ll n = 2;
while(index<100000)
{
arr[index++] = val;
val+=n;
n++;
}
ifstream fi("input.txt");
ofstream fo("output.txt");
char word;
string str="";
ll sum = 0;
ll cnt = 0;
while(fi>>word)
{
if(word==',')
{
if(binary_search(arr,arr+index,sum))
cnt++;
sum = 0;
str="";
}
else if(word=='\"')
{
}
else
{
str+=word;
sum+=word-'A'+1;
}
}
cout<<cnt<<"\n";
}