confidencefitch's blog

By confidencefitch, history, 4 years ago, In English

Its name is Dubious Crypto, and it was in round #657 (Div. 2). I finished my solution and tested it carefully. But when I submitted it I saw my code giving wrong answers in test 2. However, when I opened the log file, I saw that the answers did not contain some answers to the problem, making my output wrong comparing to it. It is said in the problem statement that an answer is guaranteed to be available, so as test 2 has 20 cases, I expect 20 lines in the answer, but it has only 9 (my output still has 20 answers). Below is my code, please have a look at it and explain to me what is going wrong here ? Thank you !

include

include <math.h>

int prime(long long int m,int l,int r,int j) { for (int i = l; i <= r; i++) { if ((m%i == 0)) { if ( (j > 0) ) { std::cout << i << ' ' << r << ' ' << r — j << '\n'; return 1; } else { std::cout << i << ' ' << r+j << ' ' << r << '\n'; return 1; } } } return 0; }

int chay() { int l, r; long long int m; std::cin >> l >> r >> m; for (int i = l — r; i <= r — l; i++) { if(i!=m) if(prime(m — i, l, r, i)==1); return 0; } }

int main() { int n; std::cin >> n; for (int i = 0; i < n; i++) { chay(); } }

Full text and comments »