если второй пересыпает первому, то у первого должно быть больше, а не наоборот! А если это a1 и b1, соответственно, то это и есть ответ! Потому что a1 и b1 это изначальные мерки, до пересыпаний, в задаче так описано Edited by author 22.09.2024 01:35 Edited by author 22.09.2024 01:36 Edited by author 22.09.2024 01:36 Edited by author 22.09.2024 01:37 Edited by author 17.10.2022 09:55 Edited by author 17.10.2022 09:55 Why i get RuntimeError? using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Diagnostics; using System.Globalization; namespace AlgorytmyInternetowe { public class Program { public static void Main(string[] args) { //string[] tmp = Console.In.ReadToEnd().Split(new char[] { ' ' }); string[] tmp = Console.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Console.Write(int.Parse(tmp[0])-int.Parse(tmp[4])+" "+ (int.Parse(tmp[1]) - int.Parse(tmp[3]))); } } } #include <iostream> using namespace std; main() { int a, b ; int a1 , b1; int a2 , b2; cin >> a >> b; cin >> a1 >> b1; cin >> a2 >> b2;
int c = b - b1; int c1 = a - a2; cout << c1 << " " << c; return 0; } ____________________________________ Держите) Не правильно #include <iostream> using namespace std; main() { int a, b ; int a1 , b1; int a2 , b2; cin >> a >> b; cin >> a1 >> b1; cin >> a2 >> b2;
int c = b - b1; int c1 = a - a2; cout << c1 << " " << c; return 0; } ____________________________________ Держите) In Idea my code works, but here is a runtime error: import java.util.Scanner; public class MathematiciansAndBerries { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); byte a1 = scanner.nextByte(); byte b1 = scanner.nextByte(); byte a2 = scanner.nextByte(); byte b2 = scanner.nextByte(); byte a3 = scanner.nextByte(); byte b3 = scanner.nextByte(); System.out.println((a1 - a3) + " " + (b1 - b2)); } } Help pls, why runtime error occurs? Edited by author 06.12.2018 21:47 Changed byte to int and now it works ok here. Idiotic. I don't think a mathematician can bring more than 127 kg)) "0 <= ai, bi <= 10,000" Sure, do not read condition is idiotic. тест в примере верный? если нет можно правильный? Why do you think example is wrong? Person A has 1kg of berries in 0kg basket. Person B has 1kg of berries in 1kg basket. What's in Test case 12? Edited by author 12.09.2018 23:08 #include <bits/stdc++.h> using namespace std; int main() { int a, a2, a3; int b, b2, b3; scanf("%d %d %d %d %d %d", &a, &b, &a2, &b2, &a3, &b3); int bb1 = a - a3; int bb2 = b - b2; printf("%d %d\n", bb1, bb2); return 0; } В примере, в результате написано "1 1", однако в вычислениях мы видим "1 2 - 2 1 - 0 3". Откуда, спрашивается, взялась еще одна единица? Каждый собрал по 1 кг, при пересыпаниях туда-сюда получаем 0кг и 2кг и наоборот. Объясните нормально условие Baskets weight something. Weight isn't fixed, isn't the same and should be found to receive program solution. In the example first basket weights 0 kg (plastic packet?). Second basket weights 1 kg. Edited by author 20.10.2016 14:58 См. пример. Лично меня это сбило Edited by author 07.03.2016 21:36 Не обращай внимания и все #include <iostream> using namespace std; int main() { int a[3],b[3]; for (int i = 0;i<3;i++) {cin>>a[i]>>b[i]; } cout<<a[0]-a[2]<<b[0]-b[1]; return 0; } You forgot the space. Where am I must write the space? Only in output? between ans1 << " " << ans2; var a:integer; b:integer; va:integer; vb:integer; ea:integer; eb:integer; ra:integer; rb:integer; boxa:integer; boxb:integer; begin readln(a,b); readln(va,vb);
boxb:=b-(va-a); rb:=b-boxb; readln(ea,eb); boxa:=va-(eb-vb);
writeln(a-boxa,' ',b-boxb);
end. parsing in just one line XD from string import * from functools import * [[a1,b1],[a2,b2],[a3,b3]] = map(partial(map,int),map(split,map(raw_input, [""]*3))) & in py3k: from functools import * [[a1,b1],[a2,b2],[a3,b3]] = map(partial(map,int),map(lambda x:x.split(),map(input, [""]*3))) Edited by author 05.04.2014 04:37 a1, b1 = [int(num) for num in input().split()] a2, b2 = [int(num) for num in input().split()] a3, b3 = [int(num) for num in input().split()] print(a1 - a3, b1 - b2) #include <iostream> using namespace std; int main() { int a[3]; int b[3]; int sum,m1,m2; cin>>a[0]>>b[0]; if(a[0]<0||b[0]<0||a[0]>10000||b[0]>10000) exit(1); sum=a[0]+b[0]; cin>>a[1]>>b[1]; if(a[1]<0||b[1]<0||a[1]>10000||b[1]>10000) exit(1); if(b[1]>b[0]||(a[1]+b[1]!=sum))exit(1); cin>>a[2]>>b[2]; if(a[2]<0||b[2]<0||a[2]>10000||b[2]>10000) exit(1); if(a[2]>a[0]||(a[2]+b[2]!=sum))exit(1); m1=a[0]-a[2]; m2=b[0]-b[1]; cout<<m1<<' '<<m2; return 0; } Edited by author 05.03.2014 20:47 please give me a test for WA4. According to my current logic result should be (filled bucket weight - empty bucket weight) for each mathematician. Edited by author 11.12.2013 19:12 Try this test: 7 5 9 3 4 8 Answer: 3 2 |
|