forked from zhblue/hustoj
-
Notifications
You must be signed in to change notification settings - Fork 0
/
A+B.xml
156 lines (151 loc) · 4.57 KB
/
A+B.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?xml version="1.0" encoding="UTF-8"?>
<fps version="1.2" url="https://github.com/zhblue/freeproblemset/">
<generator name="HUSTOJ" url="https://github.com/zhblue/hustoj/"/>
<item>
<title><![CDATA[送分题-A+B Problem]]></title>
<time_limit unit="s"><![CDATA[1]]></time_limit>
<memory_limit unit="mb"><![CDATA[256]]></memory_limit>
<description><![CDATA[<p>Calculate a+b</p>]]></description>
<input><![CDATA[<p>Two integer a,b (0<=a,b<=10)</p>]]></input>
<output><![CDATA[<p>Output a+b</p>]]></output>
<sample_input><![CDATA[1 2]]></sample_input>
<sample_output><![CDATA[3]]></sample_output>
<test_input><![CDATA[500 17]]></test_input>
<test_output><![CDATA[517]]></test_output>
<test_input><![CDATA[2 3
]]></test_input>
<test_output><![CDATA[5
]]></test_output>
<hint><![CDATA[<p>Q: Where are the input and the output? A: Your program shall always <font color="#ff0000">read input from stdin (Standard Input) and write output to stdout (Standard Output)</font>. For example, you can use 'scanf' in C or 'cin' in C++ to read from stdin, and use 'printf' in C or 'cout' in C++ to write to stdout. You <font color="#ff0000">shall not output any extra data</font> to standard output other than that required by the problem, otherwise you will get a "Wrong Answer". User programs are not allowed to open and read from/write to files. You will get a "Runtime Error" or a "Wrong Answer" if you try to do so. Here is a sample solution for problem 1000 using C++/G++:</p>
<pre>
#include <iostream>
using namespace std;
int main()
{
int a,b;
cin >> a >> b;
cout << a+b << endl;
return 0;
}</pre>
<p>It's important that the return type of main() must be int when you use G++/GCC,or you may get compile error. Here is a sample solution for problem 1000 using C/GCC:</p>
<pre>
#include <stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a, &b);
printf("%d\n",a+b);
return 0;
}</pre>
<p>Here is a sample solution for problem 1000 using PASCAL:</p>
<pre>
program p1000(Input,Output);
var
a,b:Integer;
begin
Readln(a,b);
Writeln(a+b);
end.</pre>
<p>Here is a sample solution for problem 1000 using JAVA: Now java compiler is jdk 1.5, next is program for 1000</p>
<pre>
import java.io.*;
import java.util.*;
public class Main
{
public static void main(String args[]) throws Exception
{
Scanner cin=new Scanner(System.in);
int a=cin.nextInt();
int b=cin.nextInt();
System.out.println(a+b);
}
}</pre>
<p>Old program for jdk 1.4</p>
<pre>
import java.io.*;
import java.util.*;
public class Main
{
public static void main (String args[]) throws Exception
{
BufferedReader stdin =
new BufferedReader(
new InputStreamReader(System.in));
String line = stdin.readLine();
StringTokenizer st = new StringTokenizer(line);
int a = Integer.parseInt(st.nextToken());
int b = Integer.parseInt(st.nextToken());
System.out.println(a+b);
}
}</pre>]]></hint>
<source><![CDATA[系统原理,熟悉OJ]]></source>
<solution language="C"><![CDATA[#include <stdio.h>
int main()
{
int a,b;
while(scanf("%d%d",&a,&b)!=EOF)
{
printf("%d\n",a+b);
}
return 0;
}]]></solution>
<solution language="C++"><![CDATA[#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
int a,b;
while(cin >>a >>b)
{
cout <<a+b <<endl;
}
return 0;
}]]></solution>
<solution language="Pascal"><![CDATA[program abprob;
var
a,b:longint;
begin
readln(a,b);
writeln(a+b);
end.]]></solution>
<solution language="Java"><![CDATA[import java.util.*;
public class Main
{
public static void main(String args[])
{
Scanner cin = new Scanner(System.in);
int a,b;
while(cin.hasNextInt())
{
a = cin.nextInt();
b = cin.nextInt();
System.out.println(a+b);
}
}
}]]></solution>
<solution language="Bash"><![CDATA[read a b
let c=$a+$b
echo $c]]></solution>
<solution language="Python"><![CDATA[#!/usr/bin/python2
a=raw_input()
b=a.split(" ")
print eval(b[0]+"+"+b[1])
]]></solution>
<solution language="C#"><![CDATA[using System;
class Program {
public static void Main() {
string line;
string []p;
int a,b;
while((line=Console.ReadLine())!=null){
p=line.Split(' ');
a=int.Parse(p[0]);b=int.Parse(p[1]);
Console.WriteLine(a+b);
}
}
}]]></solution>
</item>
</fps>