-
Notifications
You must be signed in to change notification settings - Fork 59
/
fps-zhblue-A+B.xml
343 lines (312 loc) · 8.8 KB
/
fps-zhblue-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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fps PUBLIC
"-//freeproblemset//An opensource XML standard for AlgorithmContest Problem Set//EN"
"http://hustoj.com/fps.current.dtd" >
<fps version="1.4" url="https://github.com/zhblue/freeproblemset/">
<generator name="HUSTOJ" url="https://github.com/zhblue/hustoj/"/>
<item>
<title><![CDATA[A+B Problem]]></title>
<url><![CDATA[http://demo.hustoj.com/problem.php?id=1000]]></url>
<time_limit unit="s"><![CDATA[1.000]]></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 name="test_01"><![CDATA[1 2
]]></test_input>
<test_output name="test_01"><![CDATA[3
]]></test_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 <span>read input from stdin (Standard Input) and write output to stdout (Standard Output)</span>. 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 <span>shall not output any extra data</span> 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>
<template language="C"><![CDATA[#include <stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d",a+b);
return 0;
}
]]></template>
<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>
<template language="C++"><![CDATA[#include <iostream>
using namespace std;
int main(){
int a,b;
while(cin >> a >> b)
cout << a+b << endl;
return 0;
}
]]></template>
<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="PHP"><![CDATA[<?php
$input = stream_get_contents(STDIN);
list($a, $b) = explode(' ', $input);
echo $a + $b;
]]></solution>
<solution language="Fortran">PROGRAM P1000
IMPLICIT NONE
INTEGER :: A, B
READ(*,*) A, B
WRITE(*, '(I0)') A + B
END PROGRAM P1000
</solution>
<prepend language="Java"><![CDATA[import java.io.*;
import java.util.*;
public class Main
{
]]></prepend>
<template language="Java"><![CDATA[static int plus_2_int(int a,int b){
}]]></template>
<append language="Java"><![CDATA[ public static void main(String args[]) throws Exception
{
Scanner cin=new Scanner(System.in);
while(cin.hasNextInt()){
int a=cin.nextInt();
int b=cin.nextInt();
System.out.println(plus_2_int(a,b));
}
}
}]]></append>
<template language="Python"><![CDATA[import io
import sys
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8')
for line in sys.stdin:
a = line.split()
print(int(a[0]) + int(a[1]))
]]></template>
<template language="C#"><![CDATA[using System;
namespace HDOJ_A_Plus_B_CSharp{
class HDOJ1000 {
public static void Main() {
string line;
string []p;
int a,b;
while((line=Console.ReadLine())!=null){
if(line=="") break;
p=line.Split(' ');
a=int.Parse(p[0]);b=int.Parse(p[1]);
Console.WriteLine(a+b);
}
}
}
}
]]></template>
<template language="Obj-C"><![CDATA[#import <Foundation/Foundation.h>
int main(void)
{
int a,b;
scanf("%d %d",&a,&b);
//NSLog(@"%d",a+b);
printf("%d",a+b);
}]]></template>
<template language="Clang"><![CDATA[#include <stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d",a+b);
return 0;
}
]]></template>
<template language="Clang++"><![CDATA[#include <iostream>
using namespace std;
int main(){
int a,b;
while(cin >> a >> b)
cout << a+b << endl;
return 0;
}
]]></template>
<solution language="JavaScript"><![CDATA[process.stdin.resume();
process.stdin.setEncoding('utf-8');
var input = "";
var input_array = "";
process.stdin.on('data', function (data) {
input += data;
});
function solveMeFirst(a, b) {
return a + b;
}
process.stdin.on('end', function () {
var arr = input.split("\n");
for (var i=0; i<arr.length; i++) {
input_array=arr[i].split(" ");
var inline = 0;
var res;
var _a = parseInt(input_array[inline], 10);
inline += 1;
var _b = parseInt(input_array[inline], 10);
inline += 1;
res = solveMeFirst(_a, _b);
if(!isNaN(res) )process.stdout.write( res + "\n");
}
});
]]></solution>
<template language="JavaScript"><![CDATA[process.stdin.resume();
process.stdin.setEncoding('utf-8');
var input = "";
var input_array = "";
process.stdin.on('data', function (data) {
input += data;
});
function solveMeFirst(a, b) {
return a + b;
}
process.stdin.on('end', function () {
var arr = input.split("\n");
for (var i=0; i<arr.length; i++) {
input_array=arr[i].split(" ");
var inline = 0;
var res;
var _a = parseInt(input_array[inline], 10);
inline += 1;
var _b = parseInt(input_array[inline], 10);
inline += 1;
res = solveMeFirst(_a, _b);
if(!isNaN(res) )process.stdout.write( res + "\n");
}
});
]]></template>
<solution language="Go"><![CDATA[package main
import "fmt"
import "io"
func main() {
a:=0
b:=0
for {
_, err := fmt.Scanf("%d%d",&a,&b)
if err == io.EOF {
break
} else {
fmt.Printf("%d\n",a+b)
}
}
}]]></solution>
</item>
</fps>