forked from marioyc/Online-Judge-Solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
marioyc
committed
Jul 12, 2011
1 parent
f43b555
commit 5922a1f
Showing
8 changed files
with
229 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include <iostream> | ||
#include <cstdio> | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
int a,b; | ||
|
||
scanf("%d %d",&a,&b); | ||
|
||
printf("%d\n",a+b); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <cstdio> | ||
#include <cstring> | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
int T,x,y,L,M[101][101]; | ||
char com[6]; | ||
|
||
scanf("%d",&T); | ||
memset(M,0,sizeof(M)); | ||
|
||
while(T--){ | ||
scanf("%s %d %d %d",com,&x,&y,&L); | ||
|
||
if(com[0] == 'W'){ | ||
for(int i = 0;i < L;++i) | ||
for(int j = 0;j < L;++j) | ||
M[x+i][y+j] = 0; | ||
} | ||
|
||
if(com[0] == 'B'){ | ||
for(int i = 0;i < L;++i) | ||
for(int j = 0;j < L;++j) | ||
M[x+i][y+j] = 1; | ||
} | ||
|
||
if(com[0] == 'T'){ | ||
int ans = 0; | ||
|
||
for(int i = 0;i < L;++i) | ||
for(int j = 0;j < L;++j) | ||
ans += M[x+i][y+j]; | ||
|
||
printf("%d\n",ans); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <cstdio> | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
int T,a[5]; | ||
|
||
scanf("%d",&T); | ||
|
||
while(T--){ | ||
for(int i = 0;i < 4;++i) | ||
scanf("%d",&a[i]); | ||
|
||
int r = a[1] - a[0]; | ||
|
||
if(a[2] - a[1] == r && a[3] - a[2] == r) a[4] = a[3] + r; | ||
else a[4] = a[3] * (a[2] / a[1]); | ||
|
||
for(int i = 0;i < 5;++i){ | ||
printf("%d",a[i]); | ||
|
||
if(i == 4) putchar('\n'); | ||
else putchar(' '); | ||
} | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import java.io.BufferedReader; | ||
import java.io.InputStreamReader; | ||
import java.io.IOException; | ||
import java.math.BigInteger; | ||
|
||
public class poj1737{ | ||
public static void main(String args[]) throws IOException{ | ||
BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); | ||
|
||
BigInteger comb[][] = new BigInteger[50][51]; | ||
|
||
for(int i = 0;i < 50;++i){ | ||
comb[i][0] = BigInteger.ONE; | ||
comb[i][i+1] = BigInteger.ZERO; | ||
|
||
for(int j = 1;j <= i;++j) | ||
comb[i][j] = comb[i-1][j].add(comb[i-1][j-1]); | ||
} | ||
|
||
BigInteger two = new BigInteger("2"); | ||
BigInteger g[] = new BigInteger[51]; | ||
BigInteger f[] = new BigInteger[51]; | ||
|
||
for(int i = 1;i <= 50;++i){ | ||
g[i] = two.pow(i * (i-1) / 2); | ||
f[i] = g[i]; | ||
|
||
for(int j = 1;j < i;++j) | ||
f[i] = f[i].subtract(f[j].multiply(g[i-j]).multiply(comb[i-1][j-1])); | ||
} | ||
|
||
while(true){ | ||
int N = Integer.parseInt(in.readLine()); | ||
if(N == 0) break; | ||
|
||
System.out.println(f[N]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <cstdio> | ||
#include <cmath> | ||
#include <algorithm> | ||
|
||
using namespace std; | ||
|
||
int calc(int v, int t){ | ||
return ceil(t + 4.5 * 3600 / v); | ||
} | ||
|
||
int main(){ | ||
int N,v,t; | ||
|
||
while(true){ | ||
scanf("%d",&N); | ||
if(N == 0) break; | ||
|
||
int ans = -1; | ||
|
||
for(int i = 0;i < N;++i){ | ||
scanf("%d %d",&v,&t); | ||
|
||
if(t >= 0){ | ||
if(ans == -1) ans = calc(v,t); | ||
else ans = min(ans,calc(v,t)); | ||
} | ||
} | ||
|
||
printf("%d\n",ans); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include <cstdio> | ||
#include <algorithm> | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
int T,N,a[50000],dp1[50000],dp2[50000]; | ||
|
||
scanf("%d",&T); | ||
|
||
while(T--){ | ||
scanf("%d",&N); | ||
|
||
for(int i = 0;i < N;++i) | ||
scanf("%d",&a[i]); | ||
|
||
dp1[N-1] = a[N-1]; | ||
|
||
for(int i = N-2;i >= 0;--i) | ||
dp1[i] = a[i] + max(0,dp1[i+1]); | ||
|
||
for(int i = N-2;i >= 0;--i) | ||
dp1[i] = max(dp1[i],dp1[i+1]); | ||
|
||
dp2[0] = a[0]; | ||
|
||
for(int i = 1;i < N;++i) | ||
dp2[i] = a[i] + max(0,dp2[i-1]); | ||
|
||
for(int i = 1;i < N;++i) | ||
dp2[i] = max(dp2[i],dp2[i-1]); | ||
|
||
int ans = a[0] + a[1]; | ||
|
||
for(int i = 0;i + 1 < N;++i) | ||
ans = max(ans,dp2[i] + dp1[i+1]); | ||
|
||
printf("%d\n",ans); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <cstdio> | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
int N,M,P,C; | ||
|
||
while(true){ | ||
scanf("%d %d %d %d",&N,&M,&P,&C); | ||
if(N == 0 && M == 0 && P == 0 && C == 0) break; | ||
|
||
printf("%d\n",N+P-M); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <cstdio> | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
int T,HH,MM; | ||
|
||
scanf("%d",&T); | ||
|
||
while(T--){ | ||
scanf("%d:%d",&HH,&MM); | ||
|
||
if(MM != 0) puts("0"); | ||
else{ | ||
if(HH <= 12) printf("%d\n",HH + 12); | ||
else printf("%d\n",HH - 12); | ||
} | ||
} | ||
|
||
return 0; | ||
} |