Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ae87774

Browse files
Add late submissions for JULY17
1 parent 1b27e44 commit ae87774

File tree

5 files changed

+389
-0
lines changed

5 files changed

+389
-0
lines changed

‎LongChallenge/July17/CALC.cpp

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Deleted code is debugged code :)
3+
*/
4+
#include <bits/stdc++.h>
5+
#define ll long long
6+
#define ull unsigned long long
7+
#define vi vector<ll>
8+
#define pp pair<ll,ll>
9+
#define mp make_pair
10+
#define PI acos(-1.0)
11+
#define all(v) v.begin(),v.end()
12+
#define pb push_back
13+
#define FOR(i,a,b) for(i=a;i<b;i++)
14+
#define FREV(i,a,b) for(i=a;i>=b;i--)
15+
#define READ(a,i,n) FOR(i,0,n) { a[i] = read_ll();}
16+
#define DEBUG(x) cerr<<"In file "<< __FILE__ <<" at line "<< __LINE__ <<" :: "<< #x <<" = "<<x<<endl
17+
#define SULL(n) scanf("%llu", &n)
18+
#define INF 1e18
19+
#define MOD 1000000007
20+
21+
#ifndef ONLINE_JUDGE
22+
#define gc getchar
23+
#define pc putchar
24+
#else
25+
#define gc getchar_unlocked
26+
#define pc putchar_unlocked
27+
#endif
28+
29+
using namespace std;
30+
31+
int read_int() {
32+
char c = gc();
33+
while((c < '0' || c > '9') && c != '-') c = gc();
34+
int ret = 0, neg = 0;
35+
if (c == '-') neg = 1, c = gc();
36+
while(c >= '0' && c <= '9') {
37+
ret = 10 * ret + c - 48;
38+
c = gc();
39+
}
40+
return neg ? -ret : ret;
41+
}
42+
43+
ll read_ll() {
44+
char c = gc();
45+
while((c < '0' || c > '9') && c != '-') c = gc();
46+
ll ret = 0;
47+
int neg = 0;
48+
if (c == '-') neg = 1, c = gc();
49+
while(c >= '0' && c <= '9') {
50+
ret = 10 * ret + c - 48;
51+
c = gc();
52+
}
53+
return neg ? -ret : ret;
54+
}
55+
56+
/*******************************************RANDOM STUFF BEGINS HERE**************************************************/
57+
58+
int main() {
59+
ll i,j,t,n,b;
60+
t = read_ll();
61+
while (t--) {
62+
n = read_ll();
63+
b = read_ll();
64+
i = n/2;
65+
j = n - i;
66+
if (j%b == 0)
67+
cout << (n*n)/(4*b) << "\n";
68+
else {
69+
cout << max(((j-(j%b))/b * (i + (j%b))), ((j + (b-(j%b)))/b * (i - (b - (j%b))))) << "\n";
70+
}
71+
}
72+
return 0;
73+
}

‎LongChallenge/July17/CHEFSIGN.cpp

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*
2+
* Deleted code is debugged code :)
3+
*/
4+
#include <bits/stdc++.h>
5+
#define ll long long
6+
#define ull unsigned long long
7+
#define vi vector<ll>
8+
#define pp pair<ll,ll>
9+
#define mp make_pair
10+
#define PI acos(-1.0)
11+
#define all(v) v.begin(),v.end()
12+
#define pb push_back
13+
#define FOR(i,a,b) for(i=a;i<b;i++)
14+
#define FREV(i,a,b) for(i=a;i>=b;i--)
15+
#define READ(a,i,n) FOR(i,0,n) { a[i] = read_ll();}
16+
#define DEBUG(x) cerr<<"In file "<< __FILE__ <<" at line "<< __LINE__ <<" :: "<< #x <<" = "<<x<<endl
17+
#define SULL(n) scanf("%llu", &n)
18+
#define INF 1e18
19+
#define MOD 1000000007
20+
21+
#ifndef ONLINE_JUDGE
22+
#define gc getchar
23+
#define pc putchar
24+
#else
25+
#define gc getchar_unlocked
26+
#define pc putchar_unlocked
27+
#endif
28+
29+
using namespace std;
30+
31+
int read_int() {
32+
char c = gc();
33+
while((c < '0' || c > '9') && c != '-') c = gc();
34+
int ret = 0, neg = 0;
35+
if (c == '-') neg = 1, c = gc();
36+
while(c >= '0' && c <= '9') {
37+
ret = 10 * ret + c - 48;
38+
c = gc();
39+
}
40+
return neg ? -ret : ret;
41+
}
42+
43+
ll read_ll() {
44+
char c = gc();
45+
while((c < '0' || c > '9') && c != '-') c = gc();
46+
ll ret = 0;
47+
int neg = 0;
48+
if (c == '-') neg = 1, c = gc();
49+
while(c >= '0' && c <= '9') {
50+
ret = 10 * ret + c - 48;
51+
c = gc();
52+
}
53+
return neg ? -ret : ret;
54+
}
55+
56+
/*******************************************RANDOM STUFF BEGINS HERE**************************************************/
57+
58+
int main() {
59+
ll i,j,t,n,res;
60+
t = read_ll();
61+
string s;
62+
while (t--) {
63+
res = 0;
64+
cin >> s;
65+
n = s.length();
66+
for(i=0;i<n and s[i] != '<';i++);
67+
while (i < n) {
68+
j = 0;
69+
while (s[i] == '<' or s[i] == '=') {
70+
if (s[i] == '<')
71+
j++;
72+
i++;
73+
}
74+
if (j > res)
75+
res = j;
76+
while (i < n and s[i] != '<')
77+
i++;
78+
}
79+
80+
for(i=0;i<n and s[i] != '>';i++);
81+
while (i < n) {
82+
j = 0;
83+
while (s[i] == '>' or s[i] == '=') {
84+
if (s[i] == '>')
85+
j++;
86+
i++;
87+
}
88+
if (j > res)
89+
res = j;
90+
while (i < n and s[i] != '>')
91+
i++;
92+
}
93+
94+
cout << res + 1 << "\n";
95+
}
96+
return 0;
97+
}

‎LongChallenge/July17/EXPTREE.cpp

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
* Deleted code is debugged code :)
3+
*/
4+
#include <bits/stdc++.h>
5+
#define ll long long
6+
#define ull unsigned long long
7+
#define vi vector<ll>
8+
#define pp pair<ll,ll>
9+
#define mp make_pair
10+
#define PI acos(-1.0)
11+
#define all(v) v.begin(),v.end()
12+
#define pb push_back
13+
#define FOR(i,a,b) for(i=a;i<b;i++)
14+
#define FREV(i,a,b) for(i=a;i>=b;i--)
15+
#define READ(a,i,n) FOR(i,0,n) { a[i] = read_ll();}
16+
#define DEBUG(x) cerr<<"In file "<< __FILE__ <<" at line "<< __LINE__ <<" :: "<< #x <<" = "<<x<<endl
17+
#define S(n) scanf("%lld", &n)
18+
#define INF 1e18
19+
#define MOD1 1000000007
20+
#define MOD2 1000000009
21+
22+
#ifndef ONLINE_JUDGE
23+
#define gc getchar
24+
#define pc putchar
25+
#else
26+
#define gc getchar_unlocked
27+
#define pc putchar_unlocked
28+
#endif
29+
30+
using namespace std;
31+
32+
int read_int() {
33+
char c = gc();
34+
while((c < '0' || c > '9') && c != '-') c = gc();
35+
int ret = 0, neg = 0;
36+
if (c == '-') neg = 1, c = gc();
37+
while(c >= '0' && c <= '9') {
38+
ret = 10 * ret + c - 48;
39+
c = gc();
40+
}
41+
return neg ? -ret : ret;
42+
}
43+
44+
ll read_ll() {
45+
char c = gc();
46+
while((c < '0' || c > '9') && c != '-') c = gc();
47+
ll ret = 0;
48+
int neg = 0;
49+
if (c == '-') neg = 1, c = gc();
50+
while(c >= '0' && c <= '9') {
51+
ret = 10 * ret + c - 48;
52+
c = gc();
53+
}
54+
return neg ? -ret : ret;
55+
}
56+
57+
/*******************************************RANDOM STUFF BEGINS HERE**************************************************/
58+
59+
// Extended Euclid's Algorithm
60+
ll xGCD(ll a, ll b, ll &x, ll &y) {
61+
if(b == 0) {
62+
x = 1;
63+
y = 0;
64+
return a;
65+
}
66+
67+
ll x1, y1, gcd = xGCD(b, a % b, x1, y1);
68+
x = y1;
69+
y = x1 - (a / b) * y1;
70+
return gcd;
71+
}
72+
73+
// Multiplicative modular inverse using Extended Euclid's Algorithm
74+
ll find_inverse(ll n, ll mod) {
75+
ll x,y;
76+
xGCD(n,mod,x,y);
77+
78+
if (x < 0) {
79+
x = x + mod;
80+
}
81+
82+
return x;
83+
}
84+
85+
int main() {
86+
ll i,j,t,n;
87+
t = read_ll();
88+
while (t--) {
89+
n = read_ll();
90+
ll res1 = (1LL * (n%MOD1 * (n-1)%MOD1)%MOD1 * find_inverse((2 * (n + n -3)%MOD1)%MOD1, MOD1)%MOD1)%MOD1;
91+
ll res2 = (1LL * (n%MOD2 * (n-1)%MOD2)%MOD2 * find_inverse((2 * (n + n -3)%MOD2)%MOD2, MOD2)%MOD2)%MOD2;
92+
printf("%lld %lld\n", res1, res2);
93+
}
94+
return 0;
95+
}

‎LongChallenge/July17/IPCTRAIN.cpp

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
* Deleted code is debugged code :)
3+
*/
4+
#include <bits/stdc++.h>
5+
#define ll long long
6+
#define ull unsigned long long
7+
#define vi vector<ll>
8+
#define pp pair<ll,ll>
9+
#define mp make_pair
10+
#define PI acos(-1.0)
11+
#define all(v) v.begin(),v.end()
12+
#define pb push_back
13+
#define FOR(i,a,b) for(i=a;i<b;i++)
14+
#define FREV(i,a,b) for(i=a;i>=b;i--)
15+
#define READ(a,i,n) FOR(i,0,n) { a[i] = read_ll();}
16+
#define DEBUG(x) cerr<<"In file "<< __FILE__ <<" at line "<< __LINE__ <<" :: "<< #x <<" = "<<x<<endl
17+
#define SULL(n) scanf("%llu", &n)
18+
#define INF 1e18
19+
#define MOD 1000000007
20+
21+
#ifndef ONLINE_JUDGE
22+
#define gc getchar
23+
#define pc putchar
24+
#else
25+
#define gc getchar_unlocked
26+
#define pc putchar_unlocked
27+
#endif
28+
29+
using namespace std;
30+
31+
int read_int() {
32+
char c = gc();
33+
while((c < '0' || c > '9') && c != '-') c = gc();
34+
int ret = 0, neg = 0;
35+
if (c == '-') neg = 1, c = gc();
36+
while(c >= '0' && c <= '9') {
37+
ret = 10 * ret + c - 48;
38+
c = gc();
39+
}
40+
return neg ? -ret : ret;
41+
}
42+
43+
ll read_ll() {
44+
char c = gc();
45+
while((c < '0' || c > '9') && c != '-') c = gc();
46+
ll ret = 0;
47+
int neg = 0;
48+
if (c == '-') neg = 1, c = gc();
49+
while(c >= '0' && c <= '9') {
50+
ret = 10 * ret + c - 48;
51+
c = gc();
52+
}
53+
return neg ? -ret : ret;
54+
}
55+
56+
/*******************************************RANDOM STUFF BEGINS HERE**************************************************/
57+
58+
struct trainer {
59+
ll arrival_day;
60+
ll lectures;
61+
ll sadness;
62+
};
63+
64+
bool comp(trainer a, trainer b) {
65+
return a.arrival_day < b.arrival_day;
66+
}
67+
68+
class Prioritize {
69+
public:
70+
int operator() (pp a, pp b) {
71+
return a.first < b.first;
72+
}
73+
};
74+
75+
vector<trainer> trainers;
76+
77+
int main() {
78+
ll i,j,t,n,d;
79+
t = read_ll();
80+
while (t--) {
81+
n = read_ll();
82+
d = read_ll();
83+
priority_queue<pp, vector<pp >, Prioritize> pq;
84+
trainers.resize(n);
85+
FOR(i,0,n) {
86+
trainers[i].arrival_day = read_ll();
87+
trainers[i].lectures = read_ll();
88+
trainers[i].sadness = read_ll();
89+
}
90+
sort(all(trainers), comp);
91+
j = 0;
92+
FOR(i,1,d+1) {
93+
while (j < n and trainers[j].arrival_day == i) {
94+
pq.push(mp(trainers[j].sadness, trainers[j].lectures));
95+
j++;
96+
}
97+
98+
if (!pq.empty()) {
99+
pp saddest = pq.top();
100+
pq.pop();
101+
if (saddest.second > 1) {
102+
saddest.second -= 1;
103+
pq.push(saddest);
104+
}
105+
}
106+
}
107+
108+
ll res = 0;
109+
while (!pq.empty()) {
110+
pp left = pq.top();
111+
pq.pop();
112+
res += left.first * left.second;
113+
}
114+
cout << res << "\n";
115+
}
116+
return 0;
117+
}

‎LongChallenge/July17/NITIKA.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
n = input()
2+
3+
for i in xrange(n):
4+
s = raw_input().split()
5+
st = [x[0].capitalize() + '.' for x in s[:-1]]
6+
st += [s[-1].title()]
7+
print " ".join(st)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /