-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
485 changed files
with
34,076 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,13 @@ | ||
#include <stdio.h> | ||
|
||
int main() | ||
{ | ||
int a; | ||
int b; | ||
|
||
scanf("%d%d", &a, &b); | ||
printf("%d\n", a + b); | ||
|
||
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,203 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
int main() | ||
{ | ||
char str[1050]; | ||
|
||
int a[1000]; | ||
int b[1000]; | ||
int r[1000]; | ||
|
||
int rexp; | ||
int exp; | ||
int ta; | ||
int tb; | ||
int tr; | ||
|
||
int n; | ||
int digit; | ||
|
||
int i; | ||
int j; | ||
int k; | ||
|
||
while(scanf("%s%d", str, &n) == 2) | ||
{ | ||
for(i = 0; i < 1000; i++) | ||
{ | ||
a[i] = 0; | ||
b[i] = 0; | ||
r[i] = 0; | ||
} | ||
|
||
for(i = strlen(str) - 1; i >= 0 && str[i] != '.'; i--) | ||
{ | ||
|
||
} | ||
|
||
if(i > -1) | ||
{ | ||
for(i = strlen(str) - 1; str[i] == '0'; i--) | ||
{ | ||
str[i] = 0; | ||
} | ||
} | ||
|
||
for(i = strlen(str) - 1; i >= 0; i--) | ||
{ | ||
if(str[i] == '.') | ||
{ | ||
exp = (strlen(str) - 1 - i) * -1; | ||
break; | ||
} | ||
} | ||
|
||
if(i == -1) | ||
{ | ||
exp = 0; | ||
} | ||
|
||
rexp = exp * n; | ||
|
||
j = 0; | ||
for(i = strlen(str) - 1; i >= 0; i--) | ||
{ | ||
if(str[i] >= '0' && str[i] <= '9') | ||
{ | ||
a[j] = str[i] - '0'; | ||
b[j] = str[i] - '0'; | ||
j++; | ||
} | ||
else if(str[i] == '.') | ||
{ | ||
continue; | ||
} | ||
} | ||
|
||
for(i = 1; i < n; i++) | ||
{ | ||
for(j = 0; j < 1000; j++) | ||
{ | ||
r[j] = 0; | ||
} | ||
|
||
ta = 999; | ||
tb = 999; | ||
while(a[ta] == 0) | ||
ta--; | ||
ta++; | ||
while(b[tb] == 0) | ||
tb--; | ||
tb++; | ||
|
||
for(j = 0; j < ta; j++) | ||
{ | ||
for(k = 0; k < tb; k++) | ||
{ | ||
r[k + j] = r[k + j] + b[k] * a[j]; | ||
if(r[k + j] > 9) | ||
{ | ||
r[k + j + 1] = r[k + j + 1] + r[k + j] / 10; | ||
r[k + j] = r[k + j] % 10; | ||
} | ||
} | ||
} | ||
|
||
for(j = 0; j < 1000; j++) | ||
{ | ||
b[j] = r[j]; | ||
} | ||
} | ||
|
||
if(n > 1) | ||
{ | ||
tr = 999; | ||
while(r[tr] == 0) | ||
tr--; | ||
tr++; | ||
|
||
if(exp == 0) | ||
{ | ||
for(j = tr - 1; j >= 0; j--) | ||
{ | ||
printf("%d", r[j]); | ||
} | ||
printf("\n"); | ||
} | ||
else if(-exp * n >= tr) | ||
{ | ||
printf("."); | ||
for(j = 0; j < (-exp * n) - tr; j++) | ||
{ | ||
printf("0"); | ||
} | ||
for(j = tr - 1; j >= 0; j--) | ||
{ | ||
printf("%d", r[j]); | ||
} | ||
printf("\n"); | ||
} | ||
else | ||
{ | ||
for(j = tr - 1; j >= 0; j--) | ||
{ | ||
printf("%d", r[j]); | ||
if(j == -exp * n) | ||
{ | ||
printf("."); | ||
} | ||
} | ||
printf("\n"); | ||
} | ||
} | ||
else if(n == 1) | ||
{ | ||
for(j = 0; j < 1000; j++) | ||
{ | ||
r[j] = a[j]; | ||
} | ||
tr = 999; | ||
while(r[tr] == 0) | ||
tr--; | ||
tr++; | ||
|
||
if(exp == 0) | ||
{ | ||
for(j = tr - 1; j >= 0; j--) | ||
{ | ||
printf("%d", r[j]); | ||
} | ||
printf("\n"); | ||
} | ||
else if(-exp * n >= tr) | ||
{ | ||
printf("."); | ||
for(j = 0; j < (-exp * n) - tr; j++) | ||
{ | ||
printf("0"); | ||
} | ||
for(j = tr - 1; j >= 0; j--) | ||
{ | ||
printf("%d", r[j]); | ||
} | ||
printf("\n"); | ||
} | ||
else | ||
{ | ||
for(j = tr - 1; j >= 0; j--) | ||
{ | ||
printf("%d", r[j]); | ||
if(j == -exp * n) | ||
{ | ||
printf("."); | ||
} | ||
} | ||
printf("\n"); | ||
} | ||
} | ||
} | ||
|
||
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,159 @@ | ||
#define _CRT_SECURE_NO_WARNINGS | ||
#include <algorithm> | ||
#include <cstdio> | ||
#include <cstdlib> | ||
#include <cstring> | ||
using namespace std; | ||
|
||
#define MAX 10000000 | ||
int a[100000]; | ||
|
||
void normalize(char si[], char sj[]) | ||
{ | ||
int i; | ||
int j; | ||
|
||
i = 0; | ||
j = 0; | ||
while(si[i] != 0){ | ||
if(si[i] != '-'){ | ||
sj[j] = si[i]; | ||
i++; | ||
j++; | ||
}else{ | ||
i++; | ||
} | ||
} | ||
sj[j] = 0; | ||
} | ||
|
||
int getdigit(char c) | ||
{ | ||
if(c >= '0' && c <= '9'){ | ||
return c - '0'; | ||
}else if(c >= 'a' && c <= 'z'){ | ||
return getdigit(c - 'a' + 'A'); | ||
}else if(c >= 'A' && c <= 'Z'){ | ||
switch(c){ | ||
case 'A': | ||
case 'B': | ||
case 'C': | ||
return 2; | ||
case 'D': | ||
case 'E': | ||
case 'F': | ||
return 3; | ||
case 'G': | ||
case 'H': | ||
case 'I': | ||
return 4; | ||
case 'J': | ||
case 'K': | ||
case 'L': | ||
return 5; | ||
case 'M': | ||
case 'N': | ||
case 'O': | ||
return 6; | ||
case 'P': | ||
//case 'Q': | ||
case 'R': | ||
case 'S': | ||
return 7; | ||
case 'T': | ||
case 'U': | ||
case 'V': | ||
return 8; | ||
case 'W': | ||
case 'X': | ||
case 'Y': | ||
return 9; | ||
//case 'Z': | ||
default: | ||
return -1; | ||
} | ||
}else{ | ||
return -1; | ||
} | ||
} | ||
|
||
int getphone(char s[]) | ||
{ | ||
int i; | ||
int d; | ||
int len; | ||
int result; | ||
|
||
result = 0; | ||
len = strlen(s); | ||
for(i = 0; i < len; i++){ | ||
d = getdigit(s[i]); | ||
if(d == -1){ | ||
printf("ERROR\n"); | ||
} | ||
result = result * 10 + d; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
int comparator(const void *a, const void *b) | ||
{ | ||
return *((int *)a) - *((int *)b); | ||
} | ||
|
||
int main() | ||
{ | ||
int n; | ||
int i; | ||
int j; | ||
char si[1000]; | ||
char sj[1000]; | ||
int phone_num; | ||
bool duplicate; | ||
|
||
while(true){ | ||
if(scanf("%d", &n) != 1){ | ||
break; | ||
} | ||
|
||
duplicate = false; | ||
for(i = 0; i < n; i++){ | ||
scanf("%s", si); | ||
normalize(si, sj); | ||
phone_num = getphone(sj); | ||
a[i] = phone_num; | ||
} | ||
qsort(a, n, sizeof(int), comparator); | ||
|
||
i = 0; | ||
while(true){ | ||
if(i >= n){ | ||
break; | ||
} | ||
|
||
j = i + 1; | ||
while(true){ | ||
if(j >= n || a[j] != a[i]){ | ||
break; | ||
}else{ | ||
j++; | ||
} | ||
} | ||
if(j - i >= 2){ | ||
duplicate = true; | ||
printf("%03d-%04d %d\n", a[i] / 10000, a[i] % 10000, j - i); | ||
} | ||
|
||
i = j; | ||
} | ||
|
||
if(duplicate == false) | ||
{ | ||
printf("No duplicates.\n"); | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
|
Oops, something went wrong.