Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
what answer in python | krisanapat | 1000. A+B Problem | 5 авг 2015 18:09 | 5 |
hahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahaha a = input() b = input() print a + b it is wrong answer, why? the example code in "how to write python solutions" is functional programming style. I supposed thats what is acceptable. By the way, neither works with raw_input() and int() you should try to use raw_input().split() because the input is in the same line listname[0]+listname[1] I won't include the correct solution Edited by author 05.08.2015 18:11 Edited by author 05.08.2015 18:12 |
What is wrong? Что не так? // С++ | Kelife | 1000. A+B Problem | 15 июл 2015 21:22 | 4 |
#include <iostream> using namespace std; int main() { int a, b; cout << "Enter 'a': "; cin >> a; cout << '\n'; cout << "Enter 'b': "; cin >> b; cout <<'\n'; cout << a + b; return 0; } Edited by author 07.06.2015 21:38 Edited by author 07.06.2015 21:38 Don't output "Enter a" or something like that Don't output "Enter a" or something like that Значения a и b вводятся через пробел, поэтому надо использовать только cin >> a >> b; |
Please help me to find the error | Md. Asif Imrul | 1000. A+B Problem | 6 июн 2015 16:58 | 3 |
I want to submit the solution in C language. What language I should choose from the option and what is the error in following coding:- #include <stdio.h> int main() { double a,b; scanf("%lf %lf",&a,&b); printf("%lf",a+b); return 0; } Edited by author 31.03.2015 20:19 Use integral type (int, long, long long) or set precision in output format string printf("%0.0lf",a+b); |
1000 what's the problem? | dds861 | 1000. A+B Problem | 15 май 2015 01:45 | 2 |
#include <iostream> int main() { int a=1+5; std::cout<<a; } Input numbers are not always 1 and 5, they are given to your stdin. |
Runtime Error in Java | DanLong | 1000. A+B Problem | 16 мар 2015 19:20 | 3 |
import java.io.BufferedReader; import java.io.InputStreamReader; public class AB { public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); int a = Integer.parseInt(reader.readLine()); int b = Integer.parseInt(reader.readLine()); System.out.println(a+b); } } У меня такое же решение. Тоже не принимает... Numbers are located at the same line. So, first call of readLine() give you "a b", and second - null. |
Wrong answer -- в чем проблема??? | Pavel | 1000. A+B Problem | 26 фев 2015 11:56 | 2 |
#include <iostream> using namespace std; int main() { int a, b; cout << "Enter the first number: "; cin >> a; cout << "Enter the second number: "; cin >> b; cout <<"the result: "<< a + b << endl; return 0; } Комментарии к вводу уберите |
Please, what's wrong with my code | Taiwo Azeez | 1000. A+B Problem | 20 дек 2014 11:02 | 4 |
import java.io.*; import java.util.*; public class TokenExplain { public static void main(String[] args) throws IOException { //this program gets two tokens on a single line and calculates their sum StreamTokenizer in =new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); in.nextToken(); int a=(int)in.nval; in.nextToken(); int b=(int) in.nval; System.out.println(a+b); }
} As you can see, it was well written, but when it was compiled, it took 0.078 seconds while i see fellow java coders clocking speed of 0.031, can you suggesting better classes to read inputs instead of the one i used, all other suggestions are highly welcome It has no problem and can be accepted. Yes, it was accepted but that is not the issue. The real issue is how i can optimize the code in such a way to clock 0.031 sec that others clocked. Thanks. But I cant find the code which clock 0.031 by google. Can anyone help me? |
Объясните, что не так С++ | Sapendo | 1000. A+B Problem | 17 дек 2014 16:16 | 4 |
#include <iostream> using namespace std; int main() { int a=1, b=5, sum=0; sum=a+b; cout<<sum<<endl; return 0; } Ты вводишь два числа, а не определяешь в коде. А система проверки может дать тебе любые два числа, не обязательно a=1 и b=5 ты должен ввести входные данные выводные данные |
how do i submit in python | Light | 1000. A+B Problem | 26 ноя 2014 14:29 | 2 |
a = input() b = input() a = int(a) b = int(b) c = a+b print c
this should be correct isn't it ? It is correct in Python 2, though explicit cast is excessive. In Python 3, use should add brackets after 'print'. |
Почему не принимает решение, хотя в eclipce всё правильно работает | Danila | 1000. A+B Problem | 3 окт 2014 11:20 | 2 |
import java.util.Scanner; public class Summa { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner scan=new Scanner( System.in); System.out.println("Введите значение a"); int a; a=scan.nextInt(); System.out.println("Введите значение b"); int b; b=scan.nextInt(); System.out.println(" a + b = " + (a + b)); } } You program outputs: Введите значение a Введите значение b a + b = 6 istead of just 6 Edited by author 03.10.2014 11:20 |
самое короткое решение в мире | kostan3 (kostan3@spaces.ru) | 1000. A+B Problem | 4 сен 2014 21:56 | 2 |
31 байт ни кто короче уже не сделает |
Accepted in Java 1.7 , FreePascal 2.0.4 and Visual C# 2010 | Axmadjon | 1000. A+B Problem | 6 июн 2014 12:46 | 1 |
//********************************************* //FreePascal 2.0.4 var a,b,u:longint; begin readln(a,b); for u:=1 to b do inc(a); writeln(a); end. //********************************************* //Visual C# 2010 using System; public class Sum { private static void Main() { string[] tokens = Console.ReadLine().Split(' '); Console.WriteLine(int.Parse(tokens[0]) + int.Parse(tokens[1])); } } //********************************************* //Java 1.7 import java.util.Scanner; public class test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println(sc.nextInt() + sc.nextInt()); } } |
Is there any wrong in my code for this problem | AKdeBerg | 1000. A+B Problem | 1 июн 2014 02:02 | 4 |
#include<iostream> using namespace std ; int main() { int a, b ; cout<<"Plz enter two numbers: "<<'\n' ; cin>> a >> b ; cout<<"Here is your output: "<< a + b <<'\n' ; return 0 ; } what's the wrong!!! I've written this code in c++ and submitted under visual c++2010 but they don't accept it..why????? Because you write some text in output. Remove all text. #include<iostream> using namespace std ; int main() { int a, b ; cin>> a >> b ; cout<< a + b ; return 0 ; } Like this thanks for your answer :) |
Accepted C# | Developer | 1000. A+B Problem | 14 май 2014 17:55 | 1 |
using System; public class Sum { private static void Main() { string[] tokens = Console.ReadLine().Split(' '); Console.WriteLine(int.Parse(tokens[0]) + int.Parse(tokens[1])); } } |
a + b | Straider | 1000. A+B Problem | 21 апр 2014 20:37 | 4 |
a + b Straider 10 фев 2014 23:46 import java.util.Scanner; public class firstexercise{ public static void main(String[]args){ Scanner scanner=new Scanner(System.in); int c=0; System.out.println("Введите первое число."); int a=scanner.nextInt(); System.out.println("Введите второе число."); int b=scanner.nextInt(); c=a+b; System.out.println("Ответ = " + c); } } There should be no prompt message and output only answer: import java.util.Scanner; public class firstexercise{ public static void main(String[]args){ Scanner scanner=new Scanner(System.in); int c=0; int a=scanner.nextInt(); int b=scanner.nextInt(); c=a+b; System.out.println(c); } } |
answer | abdulkhakim | 1000. A+B Problem | 28 янв 2014 15:27 | 5 |
answer abdulkhakim 2 мар 2013 21:21 #include<iostream> using namespace std; int main() { int a,b; cin>>a>>b; cout<<a+b; return 0; } after int main() need "{" |
Форма ответа как ?как на acmp. ру ? | Раимбек | 1000. A+B Problem | 28 янв 2014 15:10 | 8 |
#include <fstream> using namespace std; int main() { ifstream fin("INPUT.TXT"); ofstream fout("OUTPUT.TXT"); int a,b; fin >> a >> b; fout << a + b; fin.close(); fout.close(); } поидет ?? Мен агылшынша тiлде белмимын!! How to respond to the tasks in your site? a file or command line? tell me if the command line .. Кай жерде ' read' ? Корсетше мағам .. namespace Project1 { class Programa { static void Main() { Console.Write("Введите первое число: "); int First = Convert.ToInt32(Console.ReadLine()); Console.Write("Введите второе число: "); int Second = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Сумма числа {0} и числа {1} равна {2}", First, Second, (First + Second)); Console.ReadKey(); } } } Edited by author 18.01.2013 23:09 Edited by author 18.01.2013 23:09 or namespace Project2 { class adsf { static void Main() {
int x; int y;
x = Convert.ToInt32(Console.ReadLine()); y = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Сумма числел = " + (x+y));
Console.ReadKey(); } } } |
The worst uptimization!!! | Wasdek | 1000. A+B Problem | 28 янв 2014 15:09 | 2 |
#include <iostream> int main() { using namespace std; int a, b, buffer; cin>>a>>b; int *mass=new int[b]; int *deep=new int[33180]; for (int i4=0; i4<b; i4++) { mass[i4]=0; deep[i4]=1200; } for (int i5=b; i5<33180; i5++) { deep[i5]=a; } for (int i6=0; i6<33180; i6++) { for (int i9=1; i9<33180; i9++) { if (deep[i9-1]>deep[i9]) { buffer=deep[i9-1]; deep[i9-1]=deep[i9]; deep[i9]=buffer; } } } mass[0]=a; mass[b-1]=b; for (int i=0; i<b; i++) { for (int i2=1; i2<b; i2++) { if (mass[i2-1]>mass[i2]) { buffer=mass[i2-1]; mass[i2-1]=mass[i2]; mass[i2]=buffer; } } } int sum=0; for (int i3=0; i3<b; i3++) { sum+=mass[i3]; } cout<<sum; delete []deep; delete []mass; return 0; } This solution works 1 second and output 1 if a=1 or b=1, and get AC! |
Почему мое решение выдает ошибку? | Айарпи | 1000. A+B Problem | 28 янв 2014 14:56 | 1 |
ab = raw_input() print int(ab[0]) + int(ab[2]) |
Compilation error...why?? (Java 1.7) | 151382OF | 1000. A+B Problem | 20 янв 2014 23:35 | 1 |
package timus; class timus {
public static void main (String args[]) { int a = 1,b = 5; System.out.println(a+b); } } Edited by author 20.01.2014 23:38 Edited by author 20.01.2014 23:38 |