|
|
Common BoardDon't be afraid of geometry, this problem is really easy Please, fix English in the statement: is maked -> is made You standing -> You're standing you have made -> you made Thank you! Is it supposed to be solved without floating-point numbers at all? This problem is definitely can be solved using integers only Don't be afraid of geometry, this problem is really easy I confirm :) #include<iostream> using namespace std; int sum(int temp); int main(){ int a[6]; scanf("%1d%1d%1d%1d%1d%1d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5]); int first=a[0]*100+a[1]*10+a[2]; int second=a[3]*100+a[4]*10+a[5]; if(a[3]==9&&a[4]==9&&a[5]==9){ cout<<"No"; return 0; } int pre=second-1; int next=second+1; if((sum(pre)==(a[0]+a[1]+a[2]))||(sum(next)==(a[0]+a[1]+a[2]))){ cout<<"Yes"; }else{ cout<<"No"; }
return 0; } int sum(int temp){ int count=0; do{ count+=(temp%10); temp/=10; }while(temp/10!=0); count+=temp; return count; } #include<iostream> #include<vector> #include<string> #include<algorithm> using namespace std; class team{ public: string id; int n; }; bool comp(const team &t1,const team &t2); int main(){ int k; cin>>k; vector<team> T; while(k--){ string temp; int num; cin>>temp>>num; team t; t.id=temp; t.n=num; T.push_back(t); } stable_sort(T.begin(),T.end(),comp); for(int i=0;i<T.size();++i){ cout<<T[i].id<<" "<<T[i].n<<endl; }
return 0; } bool comp(const team &t1,const team &t2){ return t1.n>t2.n; } Why Wring answer? import java.util.Scanner; public class T1654 { public static char[] arr; public static String out = ""; public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); String inp = sc.next(); sc.close(); arr = new char[inp.length()]; arr = inp.toCharArray(); format(); if(out != "") { System.out.println(out); } else { System.out.println(""); }
}
public static void format() { boolean isFormat = false; int l = arr.length; for(int i = 0; i< l-1; i++) { if(arr[i] == arr[i+1]) { arr[i] = 0; arr[i+1] = 0; isFormat = true; } else if(arr[i] != arr[i+1] & arr[i] != 0){ out += arr[i]; } } out+= arr[arr.length-1]; if(isFormat == true) { arr = new char[out.length()]; arr = out.toCharArray(); out = ""; format(); } } } получил АС, долго искал где долбанный баг, т.к. ТЕСТ 22 выдавал ошибку по времени, если у вас такая же проблема и вы используете преобразование double в int то в 22 тесте точность P и Q 3 знака, поэтому ТЛ и выдает, вероятно на вход подаются какие нибудь числа 22.333 и 22.334 удачи You are wrong! P and Q are given with up to 2 digits after decimal point in all tests. похожая фигня, точности 2 знаков после запятой не хватало, впилил третий знак, всё заработало code like: size_t out = 0; printf ("%zu\n", out); result - > wa#1 ((( if i use printf ("%d\n", out); all test accepted (( Why? https://wandbox.org/ & gcc 7.1 - The first version works correctly ((( i have ac in 0.187 s, but on this test my program runs at least 0.9: 35 123 2 3 4 5 6 0 8 9 10 11 0 13 14 15 0 17 18 0 20 21 0 23 0 25 0 27 0 0 0 0 0 0 0 0 0 I've got accepted after adding the condition of end of file in creating new line. May be, it will be useful. Edited by author 31.01.2016 15:50 Edited by author 31.01.2016 15:50 2 5 11 as fg asdf asdfr a qwer as s s qwer e Correct answer is 5 #include<iostream> #include<vector> #include<algorithm> using namespace std; int main(){ int k; cin>>k; vector<int> line1; vector<int> line2; vector<int> sum; while(k--){ int m,n; cin>>m>>n; line1.push_back(m); line2.push_back(n); } bool plus_1=false; for(int i=line1.size()-1;i>=0;i--){ int temp=line1[i]+line2[i]; if(plus_1){ temp++; } if(temp>=10){ plus_1=true; temp-=10; }else{ plus_1=false; } sum.push_back(temp);
} for(vector<int>::reverse_iterator iter=sum.rbegin();iter!=sum.rend();++iter){ cout<<*iter; } return 0; } I've been wa on this case for a long time: abaabaaba The right answer is abaabaabaaba Can anyone please suggest the test case which might give me WA35... I have used string , also tried with character array... and KMP algorithm ..... please do reply Edited by author 27.08.2018 13:31 Aren't 'abaabaaba' a palindrome? Can anybody please give me cases for Test2 ? If you only go through the matrix and saved the minimum value, it is not the solution for that problem. Really fast. for (int k = 0; k < n; ++k) { for (int i = graph[k]._Find_first(); i < n; i = graph[k]._Find_next(i)) { graph[k] |= graph[i]; } } I created array p[1..10000000] of boolean; p[i]=true when exist i in input. But i can t prove that if length of input <=100000 then absent numb <=10000000 because if you will write all numbers from 1 to 10000000. string length will be more than 10^5 Edited by author 11.02.2019 20:58 All compilers are succeed with this code. What's wrong? #include <iostream> #include <iomanip> #include <cmath> using namespace std; int main() { double buffer[128*1024]; unsigned long long number, n=0; while(cin >> number) { buffer[n]=pow(number,1.0/2.0); n++; } for (int i=n-1;i>=0;i--) { cout << fixed << setprecision(4) << buffer[i] << endl; } return 0; } So for this test: 0 0 90 5 0 -0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 correct answer is 31.4159, right? Edited by author 01.02.2019 23:40 |
|
|