Search is not available for this dataset
name
stringlengths 2
88
| description
stringlengths 31
8.62k
| public_tests
dict | private_tests
dict | solution_type
stringclasses 2
values | programming_language
stringclasses 5
values | solution
stringlengths 1
983k
|
---|---|---|---|---|---|---|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | main(){printf("13530000\n");} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int main(void) {
int n;
int i;
double money = 100000;
scanf("%d", &n);
for (i = 0; i < n; i++) {
money *= 1.05;
}
if ((int)money % 10000 != 0) {
money = ((int)money / 10000 + 1) * 10000;
}
printf("%.0lf\n", money);
return (0);
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include<stdio.h>
main(){
int n,i,x,xx;
doble sum=100000;
scanf("%d",&n);
for(i=0;i<n;i++){
sum=sum*1.05;
x=sum/1000;
x=x*1000;
// y=sum-x;
if(sum-x > 0){
x=x+1000;
}
sum=x;
}
printf("%d\n",x);
return 0;
} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | python3 | debt=10**5
interest=5/100
n=int(input())
for week in range(n):
debt=debt*(1+interest)
if debt%1000>0:
debt=debt+1000-(debt%1000)
print(debt) |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int ans = 100000;
for (int i = 0; i < n; i++) ans += ans * 5 / 100;
if (ans % 10000) ans += (10000 - ans % 10000);
cout << ans << endl;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
double money = 100000;
cin >> n;
if (n < 100) {
for (int i = 0; i < n; i++) {
money += (money * 0.05);
}
money = ((int)money / 10000) * 10000 + 10000;
cout << money << endl;
}
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <stdio.h>
int main()
{
int d=100000,n,i;
scanf("%d",&n);
for(i=0;i<n;i++){
d*=1.05
}
d=(int)d;
if(d%10000!=0){
d = d - d%10000 +10000;
}
printf("%d\n",d);
return 0;
} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | main(n,r){for(scanf("%d",&n),r=1e5;n--;r=r%1e3?(r/1e3+1)*1e3:r)r+=r/20;printf("%d\n",r);exit(0);} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int money = 100000;
int n;
cin >> n;
while (n--) {
money *= 1.05;
}
if (money % 10000 != 0) {
money -= (money % 10000);
money += 10000;
}
cout << money << endl;
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | main(i){i=0&puts("13530000");} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int main(void) {
int n, i;
long debt;
scanf("%d", &n);
debt = 100000;
for (i = 1; i <= n; i++) {
debt = debt + debt / 20;
if (debt % 1000 != 0) {
debt = debt + (1000 - debt % 1000);
}
i++;
}
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
int main() {
int a;
std::cin >> a;
double result = 100;
for (int i = a; i; i--) {
result *= 1.05;
result = (int)(result + 0.9);
}
result *= 1000;
std::cout << result;
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int main(void) {
int n, debt, i, amari, real;
scanf("%d", &n);
debt = 100000;
for (i = 0; i < n; i++) {
debt = debt * 1.05;
}
amari = debt % 1000;
real = debt - amari + 1000;
printf("%d\n", real);
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java | package hoge.hoge.com;
import java.io.*;
import java.lang.*;
public class Main {
public static void main(String[] args) throws IOException
{
BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
int week = Integer.parseInt(buf.readLine());
System.out.println(risi(week));
}
public static int risi(int num){
double syakkin = 10; // 万円の単位まで
for(int i=0; i<num; i++){
syakkin += syakkin*0.05;
}
return (int)Math.ceil(syakkin)*10000;
}
} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | using System;
using System.Collections.Generic;
using System.Text;
namespace mondai0007
{
class Program
{
static double rishi = 0.05;
static int Main(string[] args)
{
double gankin = 100000;
double input = double.Parse(Console.ReadLine());
int zougaku = 0;
for (int i = 0; i < input; i++)
{
zougaku = (int)(gankin * rishi);
if (zougaku % 1000 != 0)
{
zougaku = (int)Math.Ceiling((double)zougaku / 1000) * 1000;
}
gankin += zougaku;
}
Console.Write(gankin.ToString());
return 0;
}
}
} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
int main(void) {
int n;
std::cin >> n;
std::cout << 10 * pow(1.05, n) << std::endl;
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int main() {
int n;
int i;
int counter = 0;
double a;
scanf("%d", &n);
for (i = 0; i < n; i++) {
if (counter == 0) {
a = 100000;
}
a = a * 1.05;
a = a / 1000;
a = ceil(a);
a = a * 1000;
counter++;
}
printf("%f\n", a);
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, debt = 100000;
cin >> n;
for (int i = 0; i < n; i++) {
debt *= 1.05;
}
debt += 9999;
debt /= 10000;
debt *= 10000;
cout << debt << endl;
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | object Main extends App {
val sc = new java.util.Scanner(System.in)
val n = sc.nextInt
var num: BigInt = 100000
for(i <- 0 until n-1) {
num += num / 20
if(num%10!=0) {
num = num / 10
num = num * 10 + 10
}
if(num%100!=0) {
num = num / 100
num = num * 100 + 100
}
if(num%1000!=1000) {
num = num / 1000
num = num * 1000 + 1000
}
}
println(num)
} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java | public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int inputNum = in.nextInt();
System.out.println(getNowShakkin(inputNum));
}
public static int getNowShakkin(int weekInterval) {
double result = 100;
for (int i = 0; i < weekInterval; i++) {
result = result + (result * 0.05);
result = (Math.ceil((double) result));
}
return (int)result * 1000;
}
} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
public class money {
public static void main(String[] args) throws IOException {
System.out.println("??´??°?????\????????????????????????");
//Input ??´??°?????\?????????
BufferedReader br =
new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();
int n = Integer.parseInt(str);
//??????
double loan = 100000;
//??\???????????´??°?????????????????????????±???????
//1??±?????¨???????????????????????????????????????????????\??????
for(int i=1; i<=n; i++){
//?????????5%?????????????????????
loan = loan * 1.05;
//?????????1000???????????????????????????
BigDecimal bd = new BigDecimal(String.valueOf(loan));
//?¬¬1?????°???0?????´???????°???°?¬¬?????????????????????(??????)
//1000??????????????????????????????????¬¬1?????°???-3??¨????????????????????????????????????
loan = bd.setScale(-3, BigDecimal.ROUND_UP).doubleValue();
}
//??¨???????????????????°???°??????????????¢??§????????????????????????????????????int??????result???????´???????
int result = (int) loan;
System.out.println(result);
}
} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int main() {
int n, i;
double d = 100000;
scanf("%d", &n);
for (i = 0; i < n; i++) {
d *= 1.05;
d = ceil(d / 1000) * 1000;
}
printf("%.0f\n", d);
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <stdio.h>
#include <math.h>
int main(void)
{
int n;
double y;
scanf("%f",&n);
printf("%f",pow(100000,y));
}
return 0;
} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int main(void) {
int n;
scanf("%d", &n);
double sum = 100000.0;
int i;
for (i = 0; i < n; i++) {
sum = sum * 1.05;
sum /= 1000.0;
sum = ceil(sum);
sum *= 1000.0;
}
int sum_i = (int)sum;
printf("%d\n", sum_i);
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | python2 | n=input()
loan=10**5
for i in xrange(n):
loan+=loan*0.05
if loan%1000!=0:
loan-=loan%1000
loan+=10**3
else:
loan-=loan%1000
print(loan) |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
int main() {
int n, i, kane = 100000, a, b;
std::cin >> n;
for (i = 0; i < n; i++) {
kane = kane * 1.05;
if (kane % 1000 != 0) {
a = kane % 1000;
b = 1000 - a;
kane = kane + b;
}
}
std::cout << kane;
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
int main() {
int n;
double debt;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
debt = debt + debt * 0.05;
}
debt = debt - (int)debt % 1000;
debt = debt + 1000;
printf("%d\n", (int)debt);
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java | package debt_hell;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
/**
* 0007:Debt Hellの解答
*
* @author MS14A
* @version 2015/04/15
*/
public class Main {
/** 初期借金額:10万円 */
private static final BigDecimal INITIAL_DEBT = BigDecimal.valueOf(100000L);
/** 利子:5% */
private static final BigDecimal INTEREST_RATE = new BigDecimal("0.05");
/** \1000未満の繰り上げ計算用 */
private static final BigDecimal DIVISOR_FOR_ROUND_UP = BigDecimal.valueOf(1000L);
/**
* n 週間後の借金の残高を出力する。<br>
* ※n は 100 以下とする。
*
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// 標準入力読み取り
int weeks = getWeeks();
// n週間後の借金額計算して表示。
System.out.println(calcDebt(weeks));
}
/**
* 標準入力を読み取り、"n"の値を返す。
*
* @return n:入力値
* @throws IOException
* 標準入力読取り失敗時
*/
private static int getWeeks() throws IOException {
InputStreamReader streamReader = new InputStreamReader(System.in);
BufferedReader bufferedReader = new BufferedReader(streamReader);
int weeks = Integer.parseInt(bufferedReader.readLine());
bufferedReader.close();
streamReader.close();
return weeks;
}
/**
* n週間後の借金額を計算する。
*
* @param weeks
* @return n週間後の借金額
*/
private static BigDecimal calcDebt(int weeks) {
BigDecimal finalDebt = INITIAL_DEBT;
for (int i = 0; i < weeks; i++) {
// 利子額計算。1000で割った小数部を繰り上げる。
BigDecimal interestAmount = finalDebt.multiply(INTEREST_RATE)
.divide(DIVISOR_FOR_ROUND_UP, 0, BigDecimal.ROUND_UP);
// 借金額 = 前週の借金額 + 利子額
finalDebt = finalDebt.add(interestAmount.multiply(DIVISOR_FOR_ROUND_UP));
}
return finalDebt;
}
} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
static float debt = 100000;
public static void main(String[] args) throws IOException {
int n;
float hell = debt;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
n = Integer.parseInt(br.readLine());
for (int i = 0; i < n; i++) {
hell += hell * 1.05;
}
System.out.println((int) hell + (hell % 100 > 0 ? 1000 : 0));
}
} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int main() {
int DEBT = 100000;
int i, n;
scanf("%d", &n);
for (i = 0; i <= n; i++) {
DEBT *= 1.05;
DEBT = (DEBT / 1000) * 1000;
}
printf("%d\n", DEBT);
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
while (cin >> n) {
int cur = 100000;
for (int i = 0; i < n; i++) {
cur = 1.05 * cur;
cur = cur / 1000 * 1000;
}
cout << cur << endl;
}
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | function Main(input){
var n=parseInt(input.split('\n')[0]),a=100;
while(n--)a+=Math.ceil(a*5/100);
console.log(a*100);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8")); |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
double x = 100000.0;
cin >> n;
for (int i = 0; i < n; i++) x += x * 0.05;
cout << (int)(x / 10000 + 0.9) * 10000;
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include<stdio.h>
int main(void)
{
int n
float p
scanf("%d",&n);
p=1.05;
for(i=0;i<n;i++){
w=100000*p;
if(1000%w>0){
w=w-(1000%w)+1000;
} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | include<stdio.h>
int main(void)
{
int n;
int debt = 100000;
scanf("%d",&n);
while ( n-- > 0 ) {
debt *= 1.05;
if ( debt % 1000 ) {
debt /= 1000;
debt += 1;
debt *= 1000;
}
}
printf("%d\n", debt);
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int main(void) {
int n, i;
int sum = 100000;
scanf("%d", &n);
for (i = 0; i < n; i++) {
sum += sum * 0.05;
}
if (sum % 1000 > 0) {
sum /= 10000;
sum *= 10000;
sum += 10000;
}
printf("%d\n", sum);
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
double n, mon = 100000;
cin >> n;
for (int i = 0; i < n; i++) {
mon = mon * 1.05;
mon = (mon + 999) - (int(mon + 999) % 1000);
}
cout << mon << endl;
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | import std.stdio,std.conv,std.string,std.math;
void main(){
double money = 100000;
while(true){
char[] buf;
stdin.readln(buf);
double x = buf.chomp().to!double();
if(0 <= x && x <= 100){
for(int i = 0;i < x;i++){
money = money + (money * 0.05);
if(money - (money/1000).to!int() * 1000 != 0){
money = ((money/1000 + 1).to!int())*1000;
}
}
break;
}else{
writeln("tryAgain!");
}
}
writeln(money);
} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | <?php
fscanf(STDIN, "%d", $n);
$debt = 100000;
for($i = 1; $i < $n; $i++){
$debt = ceil(($debt * 1.05)/1000) * 1000;
}
echo $debt."\n";
?> |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
int main() {
double yami = 100.000;
int n;
std::cin >> n;
for (int i = 0; i < n; ++i) {
yami *= 1.05;
if (ceil(yami) != floor(yami)) {
yami = ceil(yami);
}
}
yami *= 1000;
std::cout << yami << '\n';
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int main() {
int n, i;
double a = 10, j, m, o;
scanf("%d", &n);
for (i = 0; i < n; i++) {
j += a * 0.05;
}
double k = ceil(j);
m = k + 10;
o = m * 10000;
printf("%f\n", o);
return (0);
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int main(void) {
int num = 100000, n, i;
double numd;
scanf("%d", &n);
if (n <= 100 || n > 0) {
for (i = 1; i <= n; i++) {
num = num * 1.05;
}
numd = num / 1000;
numd = numd + 0.999;
num = (int)numd * 1000;
printf("%d\n", num);
}
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int main() {
int n, i, p, a = 100000;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
p = (a * 5) / 100;
a = a + p;
if (a % 1000 != 0) {
a = a - (a % 1000) + 1000;
}
}
printf("%d\n", a);
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java | import java.io.*;
class Main{
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
double x = Double.parseDouble(br.readLine());
double y = 100000;
long z = 0;
for (long i=0; i<x; i++) {
y = y + (y * 1.05);
y = y /1000;
y = Math.ceil(y);
y = y * 1000;
z = (long)y;
}
System.out.println(z);
}
} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
int main(void) {
int n, i;
scanf("%d", &n);
n = n * 5;
n = 1000 * n;
n = 100000 + n;
i = n % 10000;
if (i != 0) {
i = 10000 - i;
n = n + i;
}
printf("%d\n", n);
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int bor_money = 100000, n;
cin >> n;
for (int i = 0; i < n; i++) {
bor_money *= 1.05;
}
if (5000 <= (bor_money % 10000)) {
bor_money /= 10000;
bor_money += 1;
bor_money *= 10000;
}
cout << bor_money << endl;
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
const static double de_PI = 3.14159265358979323846;
const static int de_MOD = 1000000007;
const static int de_MAX = 999999999;
const static int de_MIN = -999999999;
int main(void) {
int a = 0;
std::cin >> a;
double n = 100000;
for (int i = 0; i < a; i++) {
n = n * 1.05;
n = static_cast<int>((n / 1000) + 0.999);
n = n * 1000;
}
std::cout << n << std::endl;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #!/usr/local/bin/ruby
n=gets.to_i
x=100000
n.times{
x=x+x*0.05
if x%1000!=0
x=x-x%1000+1000
end
}
puts"#{x}" |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java | import java.util.*;
import java.math.*;
class Main {
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
double sum = 100000;
for(int i=0;i<n;i++){
sum=sum+sum*0.05;
BigDecimal bi = new BigDecimal(String.valueOf(sum));
sum = bi.setScale(-3,BigDecimal.ROUND_UP).doubleValue();
}
System.out.printf("%.0f",sum);
}
} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int main(void) {
int n, debt, i, amari, real;
scanf("%d", &n);
debt = 100000;
for (i = 0; i < n; i++) {
debt = debt * 1.05;
amari = debt % 1000;
if (amari != 0) {
real = debt - amari + 1000;
printf("%d\n", real);
} else {
printf("%d\n", debt);
}
}
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int main(void) {
int i, n, j, k;
double debt = 100000;
scanf("%d", &n);
for (i = 0; i < n; i++) {
debt = debt * 1.05;
j = debt;
j = j / 1000 + 1;
debt = j * 1000;
}
k = debt;
printf("%d\n", k);
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int weeks = s.nextInt();
double debt = 100;
while(weeks>0){
debt = debt*1.05;
debt = (int)Math.ceil(debt);
weeks--;
}
System.out.println((int)debt*100);
}
} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | python3 | import sys
def main():
n = int(input().rstrip())
r = 1.05
digit = -4
a = 100000
print(int(round(a*(r**n), digit)))
if __name__ == '__main__':
main() |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int main(void) {
int week, money = 100000, i;
int tmp;
scanf("%d", &week);
for (i = 0; i < week; i++) {
money = money * 1.05;
tmp = money % 1000;
if (tmp > 0) {
money = money + 1000 - tmp;
}
}
printf("%d", money);
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | import Control.Applicative
main = do
w <- read <$> getLine
print $ show $ (ceiling $ ((1.05^w)*100))*1000 |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
cout << 100000 + (5000 * n + n * 1000) << endl;
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int main(void) {
int n;
int debt;
int i;
scanf("%d", &n);
debt = 100000;
for (i = 0; i < n; i++) {
debt += 5000;
if (debt / 1000 != 0) {
debt /= 1000;
debt += 1;
debt *= 1000;
}
}
printf("%d\n", debt);
return (0);
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int main(void) {
int n, money = 100000;
scanf("%d", &n);
money *= pow(1.05, n);
printf("%d\n", money / 10000 * 10000 + 10000);
return (0);
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
long double x = 100000, w;
int i, n, y;
while (cin >> n) {
for (i = 1; i <= n; i++) {
x = x * 1.05;
y = x;
y = y / 100;
x = y;
x = x / 10;
x = ceil(x);
x = x * 1000;
}
cout << x << endl;
}
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int main(void) {
int NumOfWeeks;
int CurrentDebt = 100000;
scanf("%d", NumOfWeeks);
int i;
for (i = 0; i < NumOfWeeks; i++) {
CurrentDebt = CurrentDebt / 100 + CurrentDebt;
}
printf("%d", CurrentDebt);
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
double debt = 10000;
cin >> n;
for (int i = 0; i < n; i++) {
debt *= 1.05;
}
int result = (int)debt;
result /= 1000;
result++;
result *= 1000;
cout << result << endl;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
struct omt {
omt() {
ios::sync_with_stdio(false);
cin.tie(0);
}
} star;
int main() {
double n;
cin >> n;
double ans = 100000;
for (int i = 0; i < n; i++) {
ans *= 1.05;
if ((int)ans % 1000 > 0) {
ans -= (int)ans % 1000;
ans += 1000;
}
}
cout << ans << endl;
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int main(void) {
int i, j, money = 100000, debt, week, surplus;
scanf("%d", &week);
for (i = 0; i < week; i++) {
debt = money * 1.05;
surplus = debt % 1000;
if (surplus) {
money = debt + 1000 - surplus;
}
money = debt;
}
printf("%d\r\n", debt);
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();
int weeks = Integer.parseInt(str);
long debt = (long) (100000 * Math.pow(1.05, weeks));
long debtRound = (long) Math.ceil((double) debt / 1000) * 1000;
System.out.println(debtRound);
}
} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java | import java.io.*;
class Main{
public static void main(String[]args)throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
double result = 100000;
for(int i=0; i<n; i++){
result *= 1.05;
}
result = Math.ceil(result/1000)*1000;
System.out.println((int)result);
}
} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java | import java.util.Scanner;
import java.math.BigDecimal;
public class Main{
static int calculate(int yen){
BigDecimal bd = new BigDecimal(yen*1.05);
BigDecimal bd1 = bd.setScale(-4, BigDecimal.ROUND_HALF_UP);
return bd1.intValue();
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int yen = 100000;
for(int i=0;i<n-2;i++){
yen =calculate(yen);
}
System.out.println(yen);
scan.close();
}
} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java |
/**
* @author Yuki
*/
public class Main {
/*** ??????????????? */
private static double revaluation = 1000;
/*** ?????? */
private static double rate = 1.05;
/*** ?????? */
private static double dept = 100000;
/*** ??± */
private static int week;
/**
* ?????????????????????<br>
* ??????????????????????????????
*
* @param args
* ??????????????°
*/
public static void main(String[] args) {
// ?????????
week = Integer.parseInt(args[0]);
// ????????????????????????
System.out.println(getTotalDept());
}
/**
* ?????????????????????????????? ????????????????????±???????¨??????????????¨????????????????
*
* @return ???????????????
*/
private static int getTotalDept() {
dept = 1000;
for (int i = 1; i <= week; i++) {
dept = Math.ceil(dept * rate); // ????????????
}
return (int) (dept * revaluation);
}
} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int debt = 100000;
int week;
cin >> week;
for (int i = 0; i < week; ++i) {
(debt /= 100) *= 105;
if (debt % 1000 > 0) {
++debt;
debt *= 1000;
}
}
cout << debt << endl;
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | include <stdio.h>
int main(void){
int n, i, debt;
debt=100000;
scanf("%d", &n);
for(i=0; i<n; i++){
debt=debt+(debt/20);
if(debt%1000!=0)
debt=debt+(1000-(debt%1000));
}
printf("%d", debt);
return 0;
} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
int main() {
int n;
int a = 100;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
if (a % 100) {
a = a * 1.05 + 1;
} else {
a *= 1.05;
}
}
printf("%d000\n", a);
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | import std.stdio;
import std.string;
import std.conv;
import std.math;
void main ()
{
double a = 100000;
int n = to!int(chomp(readln()));
foreach (i; 0 .. n)
{
a = ceil(a * 1.05 / 1000.0) * 1000;
}
writeln(to!int(a));
} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | import std.stdio,std.conv,std.string,std.math;
void main(){
double money = 100000;
while(true){
char[] buf;
stdin.readln(buf);
double x = buf.chomp().to!double();
if(0 <= x && x <= 100){
for(int i = 0;i < x;i++){
money *= 1.05;
}
break;
}else{
writeln("tryAgain!");
}
}
writeln(roundup(money));
}
int roundup(double x){
int result = 0;
result = ceil(x/10000).to!int();
return result * 10000;
} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, debt = 100000;
double risi = 1.05;
cin >> n;
for (int i = 0; i < n; i++) {
debt *= risi;
cout << debt << endl;
if (debt % 1000 > 0) debt += 1000 - (debt % 1000);
}
cout << debt << endl;
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | print("??´??° n")
n = gets.chomp.to_i
sum = 100000
for i in 1..n
sum = sum * 1.05
amari = sum%1000
if amari!=0
sum = sum + 1000 - amari
end
end
print sum.to_i.to_s |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class Main {
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0007&lang=jp
public static void main(String args[]) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
double result = 100;
for(int i = 0; i < n; i++){
result = Math.ceil(result*1.05);
}
System.out.println(result * 1000);
}
} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int week = scan.nextInt();
double debt = 100000;
for(int i = 0; i < week; i++) {
debt *= 1.05;
}
int ans = (int)(debt * 0.0001 + 0.999)*10000;
System.out.println(ans);
}
} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | python3 | import math
a = 100000
for n in range(int(input())):
a = math.ceil(a*105/100)
print(int(a)) |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
static float debt = 100000;
public static void main(String[] args) throws IOException {
int n;
float hell = debt;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
n = Integer.parseInt(br.readLine());
for (int i = 1; i <= n; i++) {
hell += hell * 0.05;
}
System.out.println((int) hell + (hell % 100 > 0 ? 1000 : 0));
}
} |
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int main(void) {
int a, b = 100000, c, i;
scanf("%d", &a);
for (i = 1; i <= a; i++) {
b = b * 1.05;
}
if (b % 1000 != 0) {
c = b / 10000 + 1;
}
printf("%d", c * 10000);
return 0;
}
|
p00007 Debt Hell | Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.
Write a program which computes the amount of the debt in n weeks.
Input
An integer n (0 ≤ n ≤ 100) is given in a line.
Output
Print the amout of the debt in a line.
Example
Input
5
Output
130000 | {
"input": [
"5"
],
"output": [
"130000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | n;main(d){for(d=scanf("%d",&n)+99;n--;d=d*1.05+.99);n=!printf("%d",d*1000);} |
p00139 Snakes | In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well.
For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish.
Class B ends with "~~" after "> ^" followed by one or more "Q =".
Example of type A:>'==== # ==== ~>'== # == ~
Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~
Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do.
Input
The input is given in the following format:
n
S1
S2
::
Sn
The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to.
Output
Print the i-th snake type A, B or NA on line i.
Example
Input
3
>'======#======~
>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~
>'===#====~
Output
A
B
NA | {
"input": [
"3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~"
],
"output": [
"A\nB\nNA"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<iostream>
#include<regex>
#include<string>
int main()
{
int n;
std::cin >> n;
std::cin.ignore();
while( n-- )
{
std::string s;
std::getline( std::cin, s );
std::smatch m;
if( std::regex_match( s, m, std::regex( ">\'(=+)#(=+)~" ) ) && m[1].length() == m[2].length() )
std::cout << 'A' << std::endl;
else if( std::regex_match( s, std::regex( ">^(Q=)+~~" ) ) )
std::cout << 'B' << std::endl;
else
std::cout << "NA" << std::endl;
}
return 0;
} |
p00139 Snakes | In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well.
For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish.
Class B ends with "~~" after "> ^" followed by one or more "Q =".
Example of type A:>'==== # ==== ~>'== # == ~
Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~
Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do.
Input
The input is given in the following format:
n
S1
S2
::
Sn
The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to.
Output
Print the i-th snake type A, B or NA on line i.
Example
Input
3
>'======#======~
>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~
>'===#====~
Output
A
B
NA | {
"input": [
"3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~"
],
"output": [
"A\nB\nNA"
]
} | {
"input": [],
"output": []
} | CORRECT | python3 | import re
SNAKE_A = re.compile(r">'(=+)#\1~")
SNAKE_B = re.compile(r">\^(Q=)+~~")
def answer(regex, string, output):
result = regex.fullmatch(string)
if result is not None:
print(output)
else:
print("NA")
for _ in range(int(input())):
snake = input()
if snake[1] == "'":
answer(SNAKE_A, snake, "A")
else:
answer(SNAKE_B, snake, "B")
|
p00139 Snakes | In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well.
For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish.
Class B ends with "~~" after "> ^" followed by one or more "Q =".
Example of type A:>'==== # ==== ~>'== # == ~
Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~
Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do.
Input
The input is given in the following format:
n
S1
S2
::
Sn
The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to.
Output
Print the i-th snake type A, B or NA on line i.
Example
Input
3
>'======#======~
>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~
>'===#====~
Output
A
B
NA | {
"input": [
"3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~"
],
"output": [
"A\nB\nNA"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
signed main(){
int n;
cin>>n;
rep(i,0,n){
string s;
cin>>s;
int ans=0;
int sz=s.size();
if(sz<6){
ans=-1;
}else if(s[0]=='>'&&s[1]=='\''&&s[sz-1]=='~'&&sz%2==0&&s[sz/2]=='#'){
rep(i,2,sz-1){
if(i!=sz/2&&s[i]!='='){
ans=-1; break;
}
if(i==sz-2) ans=1;
}
}else if(s[0]=='>'&&s[1]=='^'&&s[sz-2]=='~'&&s[sz-1]=='~'&&sz%2==0){
rep(i,2,sz-2){
if(i%2==0&&s[i]!='Q'){
ans=-1; break;
}if(i%2&&s[i]!='='){
ans=-1; break;
}
if(i==sz-3) ans=2;
}
}else{
ans=-1;
}
if(ans==-1) o("NA");
else if(ans==1) o("A");
else if(ans==2) o("B");
}
} |
p00139 Snakes | In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well.
For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish.
Class B ends with "~~" after "> ^" followed by one or more "Q =".
Example of type A:>'==== # ==== ~>'== # == ~
Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~
Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do.
Input
The input is given in the following format:
n
S1
S2
::
Sn
The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to.
Output
Print the i-th snake type A, B or NA on line i.
Example
Input
3
>'======#======~
>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~
>'===#====~
Output
A
B
NA | {
"input": [
"3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~"
],
"output": [
"A\nB\nNA"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<iostream>
using namespace std;
string in;
int isA(){
if(in.length() < 5) return 0;
if(in[0] != '>') return 0;
if(in[1] != '\'') return 0;
if(!(in[in.length()-1] == '~' && in[in.length()-2] == '=')) return 0;
int data[2] = {0,0};
int status = 0;
for(int i = 2; i < in.length()-1; i++){
if(in[i] == '#') status = 1;
if(in[i] == '=') data[status]++;
if(in[i] != '#' && in[i] != '=') return 0;
}
if(data[0] && data[0] == data[1]) return 1;
return 0;
}
int isB(){
if(in.length() < 5) return 0;
if(in[0] != '>') return 0;
if(in[1] != '^') return 0;
if(!(in[in.length()-1] == '~' && in[in.length()-2] == '~')) return 0;
for(int i = 2; i < in.length()-2; i+=2){
if(!(in[i] == 'Q' && in[i+1] == '=')) return 0;
}
return 1;
}
int main(){
int num;
cin >> num;
for(int i = 0; i < num; i++){
cin >> in;
if(isA()) cout << "A" << endl;
else if(isB()) cout << "B" << endl;
else cout << "NA" << endl;
}
return 0;
} |
p00139 Snakes | In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well.
For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish.
Class B ends with "~~" after "> ^" followed by one or more "Q =".
Example of type A:>'==== # ==== ~>'== # == ~
Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~
Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do.
Input
The input is given in the following format:
n
S1
S2
::
Sn
The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to.
Output
Print the i-th snake type A, B or NA on line i.
Example
Input
3
>'======#======~
>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~
>'===#====~
Output
A
B
NA | {
"input": [
"3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~"
],
"output": [
"A\nB\nNA"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
int a;
bool check(const string st,const int isa) {
a = 0;
if (isa) {
if (st[a] != '>')return false;
a++;
if (st[a] != '\'')return false;
a++;
int num = 0;
while (st[a] == '=') {
num++;
a++;
}
if (!num)return false;
if (st[a] != '#')return false;
a++;
int num2 = 0;
while (st[a] == '=') {
num2++;
a++;
}
if (num != num2)return false;
if (st[a] != '~')return false;
a++;
if (st[a] != ' ')return false;
return true;
}
else {
if (st[a] != '>')return false;
a++;
if (st[a] != '^')return false;
a++;
int num = 0;
while (1) {
if (st[a] == 'Q') {
num++;
a++;
if (st[a] != '=') {
return false;
}
else {
a++;
}
}
else {
break;
}
}
if (!num)return false;
if (st[a] != '~')return false;
a++;
if (st[a] != '~')return false;
a++;
if (st[a] != ' ')return false;
return true;
}
}
int main() {
int N; cin >> N;
while (N--) {
string st; cin >> st;
for (int i = 0; i < 100; ++i) {
st.push_back(' ');
}
if (check(st, true)) {
cout << "A" << endl;
}
else if (check(st, false)) {
cout << "B" << endl;
}
else {
cout << "NA" << endl;
}
}
return 0;
} |
p00139 Snakes | In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well.
For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish.
Class B ends with "~~" after "> ^" followed by one or more "Q =".
Example of type A:>'==== # ==== ~>'== # == ~
Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~
Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do.
Input
The input is given in the following format:
n
S1
S2
::
Sn
The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to.
Output
Print the i-th snake type A, B or NA on line i.
Example
Input
3
>'======#======~
>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~
>'===#====~
Output
A
B
NA | {
"input": [
"3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~"
],
"output": [
"A\nB\nNA"
]
} | {
"input": [],
"output": []
} | CORRECT | java | import java.util.Scanner;
public class Main{
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n;
n = sc.nextInt();
for (int i = 0; i < n; i++) {
String snake = sc.next();
String answer = "NA";
int index = 0;
if (6 <= snake.length()) {
if (snake.charAt(0) == '>' && snake.charAt(snake.length() - 1) == '~') {
snake = snake.substring(1, snake.length() - 1);
if (snake.charAt(0) == '\'') {
snake = snake.substring(1);
if (snake.length() % 2 == 1) {
answer = "A";
for (int j = 0; j < snake.length(); j++) {
if (j == snake.length() / 2 && snake.charAt(j) != '#') {
answer = "NA";
} else if (j != snake.length() / 2 && snake.charAt(j) != '=') {
answer = "NA";
}
}
}
} else if (snake.charAt(0) == '^' && snake.charAt(snake.length() - 1) == '~') {
snake = snake.substring(1, snake.length() - 1);
if (snake.length() % 2 == 0) {
answer = "B";
for (int j = 0; j < snake.length(); j++) {
if (j % 2 == 0 && snake.charAt(j) != 'Q') {
answer = "NA";
} else if (j % 2 == 1 && snake.charAt(j) != '=') {
answer = "NA";
}
}
}
}
}
}
System.out.println(answer);
}
}
} |
p00139 Snakes | In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well.
For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish.
Class B ends with "~~" after "> ^" followed by one or more "Q =".
Example of type A:>'==== # ==== ~>'== # == ~
Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~
Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do.
Input
The input is given in the following format:
n
S1
S2
::
Sn
The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to.
Output
Print the i-th snake type A, B or NA on line i.
Example
Input
3
>'======#======~
>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~
>'===#====~
Output
A
B
NA | {
"input": [
"3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~"
],
"output": [
"A\nB\nNA"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <iostream>
#include <string>
#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
int n;
cin >> n;
rep(i,n)
{
string s;
cin >> s;
if(s[0] == '>' && s[1] == '\'' && s[2] == '=')
{
int i = 2;
int cnt = 0;
while(s[i] == '=')
{
i++;
cnt++;
}
if(s[i] == '#' && i < s.size())
{
i++;
while(s[i] == '=')
{
if(i == s.size()-1) break;
i++;
cnt--;
}
}
if(cnt == 0 && s[i] == '~') cout << "A" << endl;
else cout << "NA" << endl;
}
else if(s[0] == '>' && s[1] == '^' && s[2] == 'Q')
{
int i = 2;
int cnt = 0;
bool end = false;
while(i+1 < s.size())
{
if(s[i] == 'Q' && s[i+1] == '=')
{
i += 2;
}
else if(s[i] == '~' && s[i+1] == '~')
{
end = true;
cout << "B" << endl;
i += 2;
}
else
{
break;
}
}
if (!end) cout << "NA" << endl;
}
else
{
cout << "NA" << endl;
}
}
return 0;
} |
p00139 Snakes | In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well.
For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish.
Class B ends with "~~" after "> ^" followed by one or more "Q =".
Example of type A:>'==== # ==== ~>'== # == ~
Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~
Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do.
Input
The input is given in the following format:
n
S1
S2
::
Sn
The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to.
Output
Print the i-th snake type A, B or NA on line i.
Example
Input
3
>'======#======~
>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~
>'===#====~
Output
A
B
NA | {
"input": [
"3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~"
],
"output": [
"A\nB\nNA"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include "bits/stdc++.h"
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define dump(x) cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
string solve(string s){
if(s.substr(0,2)==">'"){
int eq=0;
for(int i=2;i<s.size();i++){
if(s[i]!='=')break;
else{
eq++;
}
}
if(eq==0)return "NA";
if( s[ (2 + eq -1) +1 ] != '#')return "NA";
if( s.substr( ((2+eq-1)+1) +1 ,eq ) != s.substr( 2,eq ) )return "NA";
if( 2+eq+1+eq+1 == s.size() && s[ (2+eq+1+eq+1) -1 ]=='~')return "A";
}else if(s.substr(0,2)==">^"){
int c=2;
while( s[c]=='Q' && s[c+1]=='=' ){
c+=2;
}
if(c==2)return "NA";
if( c+1==s.size()-1 && s[c]=='~' && s[c+1]=='~')return "B";
else return "NA";
}else return "NA";
return "NA";
}
int main(){
int n;
cin>>n;
rep(i,n){
string s;
cin>>s;
cout<<solve(s)<<endl;
}
return 0;
} |
p00139 Snakes | In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well.
For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish.
Class B ends with "~~" after "> ^" followed by one or more "Q =".
Example of type A:>'==== # ==== ~>'== # == ~
Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~
Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do.
Input
The input is given in the following format:
n
S1
S2
::
Sn
The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to.
Output
Print the i-th snake type A, B or NA on line i.
Example
Input
3
>'======#======~
>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~
>'===#====~
Output
A
B
NA | {
"input": [
"3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~"
],
"output": [
"A\nB\nNA"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp |
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <tuple>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int DX[] = {0, 1, 0, -1};
const int DY[] = {-1, 0, 1, 0};
//other
//--------------------------------------------
#define RANGE(a, c, b) ((a <= b) && (b < c))
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int solve(string snake){
if(snake[0] != '>') return 0;
if(snake[1] == '\''){
int i = 2;
while(snake[i] == '='){
i++;
}
if(snake[i] != '#') return 0;
int length = i - 2;
i++;
while(snake[i] == '='){
i++;
}
int length2 = i -3 - length;
if(length2 != length) return 0;
if(length > 0 &&
snake[i] == '~' &&
i == snake.length() - 1){
return 1;
}
}else if(snake[1] == '^'){
int i = 2;
int length = 0;
while(snake[i] =='Q' &&
snake[i + 1] == '='){
i += 2;
length++;
}
if(length > 0 &&
snake[i] == '~' &&
snake[i + 1] == '~' &&
i + 1 == snake.length() - 1){
return 2;
}
}
return 0;
}
int main(int argc, char const *argv[])
{
int n;
cin >> n;
REP(i, n){
string snake;
cin >> snake;
string ans;
switch(solve(snake)){
case 0:
ans = "NA";
break;
case 1:
ans = "A";
break;
case 2:
ans = "B";
break;
}
cout << ans << endl;
}
return 0;
} |
p00139 Snakes | In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well.
For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish.
Class B ends with "~~" after "> ^" followed by one or more "Q =".
Example of type A:>'==== # ==== ~>'== # == ~
Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~
Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do.
Input
The input is given in the following format:
n
S1
S2
::
Sn
The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to.
Output
Print the i-th snake type A, B or NA on line i.
Example
Input
3
>'======#======~
>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~
>'===#====~
Output
A
B
NA | {
"input": [
"3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~"
],
"output": [
"A\nB\nNA"
]
} | {
"input": [],
"output": []
} | CORRECT | python3 | import re
A = ">'(=+)#\\1~$"
B = ">\^(Q=)+~~$"
for i in range(int(input())):
s = input()
r = re.match(A, s)
if re.match(A, s): print('A')
elif re.match(B, s): print('B')
else: print('NA')
|
p00139 Snakes | In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well.
For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish.
Class B ends with "~~" after "> ^" followed by one or more "Q =".
Example of type A:>'==== # ==== ~>'== # == ~
Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~
Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do.
Input
The input is given in the following format:
n
S1
S2
::
Sn
The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to.
Output
Print the i-th snake type A, B or NA on line i.
Example
Input
3
>'======#======~
>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~
>'===#====~
Output
A
B
NA | {
"input": [
"3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~"
],
"output": [
"A\nB\nNA"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | import re
snakeA = re.compile('>\'(=+)#\\1~$')
snakeB = re.compile('>\^(Q=)+~~$')
for i in xrange(input()):
s = raw_input()
if snakeA.match(s) is not None:
print "A"
elif snakeB.match(s) is not None:
print "B"
else:
print "NA" |
p00139 Snakes | In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well.
For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish.
Class B ends with "~~" after "> ^" followed by one or more "Q =".
Example of type A:>'==== # ==== ~>'== # == ~
Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~
Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do.
Input
The input is given in the following format:
n
S1
S2
::
Sn
The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to.
Output
Print the i-th snake type A, B or NA on line i.
Example
Input
3
>'======#======~
>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~
>'===#====~
Output
A
B
NA | {
"input": [
"3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~"
],
"output": [
"A\nB\nNA"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | import re
ptn_A = r'>\'(=+)#(=+)~'
ptn_B = r'>\^(Q=)+~~'
for i in range(int(raw_input())):
snake = raw_input()
matchA = re.search(ptn_A, snake)
matchB = re.search(ptn_B, snake)
if matchA and matchA.group(1) == matchA.group(2):
print 'A'
elif matchB:
print 'B'
else:
print 'NA' |
p00139 Snakes | In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well.
For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish.
Class B ends with "~~" after "> ^" followed by one or more "Q =".
Example of type A:>'==== # ==== ~>'== # == ~
Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~
Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do.
Input
The input is given in the following format:
n
S1
S2
::
Sn
The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to.
Output
Print the i-th snake type A, B or NA on line i.
Example
Input
3
>'======#======~
>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~
>'===#====~
Output
A
B
NA | {
"input": [
"3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~"
],
"output": [
"A\nB\nNA"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <iostream>
#include <string>
using namespace std;
int stateA,stateB;
int anum;
void inA(char arg){
//cout << stateA << endl;
if(stateA == 0){
if(arg == '>'){
stateA = 1;
}
}else if(stateA == 1){
if(arg == '\''){
stateA = 2;
}else{
stateA = -1;
}
}else if(stateA == 2){
if(arg == '='){
stateA = 3;
anum++;
}else{
stateA = -1;
}
}else if(stateA == 3){
if(arg == '='){
anum++;
}else if(arg == '#'){
stateA = 4;
}else{
stateA = -1;
}
}else if(stateA == 4){
if(arg == '='){
anum--;
}else{
stateA = -1;
}
if(anum==0){
stateA = 5;
}
}else if(stateA == 5){
if(arg == '~'){
stateA = 6;
}else{
stateA = -1;
}
}else if(stateA == 6){
stateA = -1;
}
}
void inB(char arg){
if(stateB == 0){
if(arg == '>'){
stateB = 1;
}else{
stateB = -1;
}
}else if(stateB == 1){
if(arg == '^'){
stateB = 2;
}else{
stateB = -1;
}
}else if(stateB == 2){
if(arg == 'Q'){
stateB = 3;
}else{
stateB = -1;
}
}else if(stateB == 3){
if(arg == '='){
stateB = 4;
}else{
stateB = -1;
}
}else if(stateB == 4){
if(arg == 'Q'){
stateB = 5;
}else if(arg == '~'){
stateB = 6;
}else{
stateB = -1;
}
}else if(stateB == 5){
if(arg == '='){
stateB = 4;
}else{
stateB = -1;
}
}else if(stateB == 6){
if(arg == '~'){
stateB = 7;
}else{
stateB = -1;
}
}else if(stateB == 7){
stateB = -1;
}
}
int main(){
int n;
string str;
cin >> n;
cin.ignore();
while(n && getline(cin,str)){
stateA=0;
stateB=0;
anum=0;
bool A=false, B=false;
int l = str.size();
for(int i=0;i<l;i++){
inA(str[i]);
inB(str[i]);
}
if(stateA == 6){
cout << "A" << endl;
}else if(stateB == 7){
cout << "B" << endl;
}else{
cout << "NA" << endl;
}
n--;
}
} |
p00139 Snakes | In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well.
For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish.
Class B ends with "~~" after "> ^" followed by one or more "Q =".
Example of type A:>'==== # ==== ~>'== # == ~
Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~
Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do.
Input
The input is given in the following format:
n
S1
S2
::
Sn
The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to.
Output
Print the i-th snake type A, B or NA on line i.
Example
Input
3
>'======#======~
>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~
>'===#====~
Output
A
B
NA | {
"input": [
"3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~"
],
"output": [
"A\nB\nNA"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int n; cin >> n;
for (int i=0; i<n; i++) {
string S; cin >> S;
if (S.size()<4) {
cout << "NA" << endl;
continue;
}
if (S.substr(0, 2)==">'" && S[S.size()-1]=='~') {
int mark = -1;
for (int j=2; j<S.size()-1; j++) {
if (S[j]=='#') mark = j;
}
bool flag = true;
for (int j=2; j<S.size()-1; j++) {
if (j==mark) continue;
if (S[j]!='=') flag = false;
}
if (flag && mark!=-1 && mark-2==S.size()-2-mark && mark-2>0) cout << 'A' << endl;
else cout << "NA" << endl;
}
else if (S[0]=='>' && S[1]=='^' && S[S.size()-2]=='~' && S[S.size()-1]=='~') {
int idx = 2, cnt = 0;
while (true) {
if (S[idx]=='Q' && S[idx+1]=='=') {
cnt++;
idx += 2;
}
else break;
}
if (cnt>0 && idx==S.size()-2) cout << 'B' << endl;
else cout << "NA" << endl;
}
else cout << "NA" << endl;
}
}
|
p00139 Snakes | In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well.
For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish.
Class B ends with "~~" after "> ^" followed by one or more "Q =".
Example of type A:>'==== # ==== ~>'== # == ~
Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~
Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do.
Input
The input is given in the following format:
n
S1
S2
::
Sn
The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to.
Output
Print the i-th snake type A, B or NA on line i.
Example
Input
3
>'======#======~
>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~
>'===#====~
Output
A
B
NA | {
"input": [
"3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~"
],
"output": [
"A\nB\nNA"
]
} | {
"input": [],
"output": []
} | CORRECT | python3 | import re
for i in range(int(input())):
s=input()
if re.match(">'(=+)#(=+)~",s):print('A')
elif re.match(">\^(Q=)+~~",s):print('B')
else:print('NA')
|
p00139 Snakes | In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well.
For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish.
Class B ends with "~~" after "> ^" followed by one or more "Q =".
Example of type A:>'==== # ==== ~>'== # == ~
Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~
Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do.
Input
The input is given in the following format:
n
S1
S2
::
Sn
The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to.
Output
Print the i-th snake type A, B or NA on line i.
Example
Input
3
>'======#======~
>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~
>'===#====~
Output
A
B
NA | {
"input": [
"3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~"
],
"output": [
"A\nB\nNA"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int check( string S )
{
//A
if( S[ 0 ] == '>' && S[ 1 ] == '\'' && S[ S.size() - 1 ] == '~' && S.size() >= 6 )
{
S = S.substr( 2, S.size() - 3 );
if( S.find_first_not_of( "#=", 0 ) != string::npos ) return 0;
string tmpB = S.substr( 0, S.find('#') );
string tmpA = S.substr( S.find( '#' ) + 1, S.size() - 1 );
return tmpB.size() == tmpA.size() ? 1 : 0;
}
//B
if( S[ 0 ] == '>' && S[ 1 ] == '^' && S[ S.size() - 1 ] == '~' && S[ S.size() - 2 ] == '~' && S.size() >= 6 )
{
S = S.substr( 2, S.size() - 4 );
if( S.find_first_not_of( "Q=", 0 ) != string::npos ) return 0;
if( S.size() % 2 != 0 ) return 0;
for( int i = 0; i < S.size(); i += 2 )
{
if( S[ i ] != 'Q' && S[ i + 1 ] != '=' ) return 0;
}
return 2;
}
return 0;
}
int main()
{
int N;
cin >> N;
vector<string> res{ "NA", "A", "B" };
string S;
while( cin >> S )
{
cout << res[ check( S ) ] << endl;
}
return 0;
} |
p00139 Snakes | In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well.
For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish.
Class B ends with "~~" after "> ^" followed by one or more "Q =".
Example of type A:>'==== # ==== ~>'== # == ~
Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~
Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do.
Input
The input is given in the following format:
n
S1
S2
::
Sn
The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to.
Output
Print the i-th snake type A, B or NA on line i.
Example
Input
3
>'======#======~
>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~
>'===#====~
Output
A
B
NA | {
"input": [
"3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~"
],
"output": [
"A\nB\nNA"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<double,int> P;
static const double eps = 10e-9;
bool isA(string str){
if(str.size() >= 1 && str[0] != '>') return false;
if(str.size() >= 2 && str[1] != '\'') return false;
int hist[] = {0,0};
for(int i=2,j=0;i<str.size()-1;i++){
if(str[i] == '='){
hist[j]++;
}
else if(str[i] == '#') j++;
else return false;
}
if(hist[0] != hist[1]) return false;
if(hist[0] == 0 || hist[1] == 0) return false;
if(str[str.size()-1] != '~') return false;
return true;
}
bool isB(string str){
if(str.size() >= 1 && str[0] != '>') return false;
if(str.size() >= 2 && str[1] != '^') return false;
if(str.size() <= 3) return false;
string rear = str.substr(2,str.size()-2);
bool isok=false;
int i;
for(i=0;i+1<rear.size();){
if(rear.substr(i,2) == "Q="){
isok=true;
i+=2;
}
else break;
}
return (i+2 == rear.size() && isok && rear.substr(i,2) == "~~");
}
int main(){
int n;
while(~scanf("%d",&n)){
for(int i=0;i<n;i++){
string str;
cin >> str;
if(isA(str)) cout << "A" << endl;
else if(isB(str)) cout << "B" << endl;
else cout << "NA" << endl;
}
}
} |
p00139 Snakes | In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well.
For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish.
Class B ends with "~~" after "> ^" followed by one or more "Q =".
Example of type A:>'==== # ==== ~>'== # == ~
Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~
Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do.
Input
The input is given in the following format:
n
S1
S2
::
Sn
The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to.
Output
Print the i-th snake type A, B or NA on line i.
Example
Input
3
>'======#======~
>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~
>'===#====~
Output
A
B
NA | {
"input": [
"3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~"
],
"output": [
"A\nB\nNA"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <ctype.h>
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <fstream>
#include <sstream>
#include <queue>
#include <exception>
#include <cmath>
#include <numeric>
#include <map>
#include <algorithm>
#include <bitset>
#include <set>
#include <functional>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
using namespace std;
typedef long long int lint;
void AOJ0139()
{
string snake;
cin >> snake;
if (snake[0] != '>') {
cout << "NA" << endl;
return;
}
//A
if (snake[1] == '\'') {
if (snake[2] != '=') {
cout << "NA" << endl;
return;
}
int eq_count = 0;
int pos = 2;
while (snake[pos] == '=') {
eq_count++;
pos++;
}
if (snake[pos] != '#') {
cout << "NA" << endl;
return;
}
pos++;
FOR(i, pos, pos + eq_count) {
if (snake[i] != '=') {
cout << "NA" << endl;
return;
}
}
pos += eq_count;
if (snake.substr(pos) != "~") {
cout << "NA" << endl;
return;
}
cout << "A" << endl;
return;
}
//B
if (snake[1] == '^') {
int Q_count = 0;
int pos = 2;
if (snake.substr(pos, 2) != "Q=") {
cout << "NA" << endl;
return;
}
while (snake.substr(pos, 2) == "Q=") {
pos += 2;
}
if (snake.substr(pos) != "~~") {
cout << "NA" << endl;
return;
}
cout << "B" << endl;
return;
}
cout << "NA" << endl;
return;
}
int main()
{
int n;
cin >> n;
REP(i, n) AOJ0139();
return 0;
} |
p00139 Snakes | In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well.
For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish.
Class B ends with "~~" after "> ^" followed by one or more "Q =".
Example of type A:>'==== # ==== ~>'== # == ~
Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~
Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do.
Input
The input is given in the following format:
n
S1
S2
::
Sn
The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to.
Output
Print the i-th snake type A, B or NA on line i.
Example
Input
3
>'======#======~
>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~
>'===#====~
Output
A
B
NA | {
"input": [
"3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~"
],
"output": [
"A\nB\nNA"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <iostream>
#include <string>
using namespace std;
string repeat(int n, string s) {
string res = "";
for (int i=0; i<n; ++i)
res += s;
return res;
}
int main() {
int N; cin >> N;
for (int i=0; i<N; ++i) {
string snake; cin >> snake;
int len = snake.size();
if (len <= 4) {
cout << "NA" << endl;
continue;
}
string A = ">'" + repeat((len - 4)/2, "=")
+ "#" + repeat((len - 4)/2, "=") + "~";
string B = ">^" + repeat((len - 4)/2, "Q=") + "~~";
if (snake == A) {
cout << "A" << endl;
} else if (snake == B) {
cout << "B" << endl;
} else {
cout << "NA" << endl;
}
}
return 0;
} |
p00139 Snakes | In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well.
For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish.
Class B ends with "~~" after "> ^" followed by one or more "Q =".
Example of type A:>'==== # ==== ~>'== # == ~
Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~
Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do.
Input
The input is given in the following format:
n
S1
S2
::
Sn
The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to.
Output
Print the i-th snake type A, B or NA on line i.
Example
Input
3
>'======#======~
>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~
>'===#====~
Output
A
B
NA | {
"input": [
"3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~"
],
"output": [
"A\nB\nNA"
]
} | {
"input": [],
"output": []
} | CORRECT | java | import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
public static void main(String[] args) throws java.io.IOException {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
while (n != 0) {
n--;
char[] snake = sc.next().toCharArray();
String ans = isSnakeA(snake) ? "A" : isSnakeB(snake) ? "B" : "NA";
System.out.println(ans);
}
}
private static boolean isSnakeA(char[] snake) {
String sa = "^>'(=+)#\\1~$";
Pattern pa = Pattern.compile(sa);
Matcher ma = pa.matcher(String.valueOf(snake));
return ma.find();
}
private static boolean isSnakeB(char[] snake) {
String sb = "^>\\^(Q=)+~~$";
Pattern pb = Pattern.compile(sb);
Matcher mb = pb.matcher(String.valueOf(snake));
return mb.find();
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.