Zoj 1350 the drunk jailer

Source: Internet
Author: User
Tags rounds

Zoj
1350 the drunk jailer

There was an incompetent prison director who went crazy one night. In 1st rounds, he opened all the prison doors, and in 2nd rounds He took 2, 4, 6 ...... The prison door was closed, 3rd rounds, 3, 6, 9 ...... If these prison doors are open, they will be closed. If they are closed, they will be opened. How many prison doors are there, how many times will they be done, and then they will be off work. There is one criminal in each prison. If the prison director can only run after work, how many criminals can he run away?

Idea: I was going to define several arrays to replace the opened and closed prison number (ultra-complicated). Later I found that, in fact, for a single prison gate, it can divide the round number in this round and operate on it. The class is added to the number of operations, including on, off, and on ...... As long as it is an odd number, it can be accumulated into the number of running ......

Code:

# Include <stdio. h> int main () {int I, J, K, G, F, a [1000], t, n; scanf ("% d", & T ); for (I = 1; I <= T; I ++) {scanf ("% d", & N); For (j = 0; j <= n-1; j ++) {A [J] = J + 1;} f = 0; For (j = 0; j <= n-1; j ++) {G = 0; for (k = 1; k <= N; k ++) {if (a [J] % K = 0) {g ++ ;}} if (G % 2 = 1) f ++;} printf ("% d \ n", f);} return 0 ;}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.