52 cards and 52 cards

Source: Internet
Author: User

52 cards and 52 cards
There are 52 cards, so that they all face up, starting from 2nd cards, where the cards at the multiples of 2 turn to face down; then starting from 3rd cards, for cards at the multiples of 3, the front is turned to the front, and the front is turned to the front. Then, the third round starts from 4th cards, the cards at the multiples of 4 follow the same rules above, and so on until the number of cards to be turned is 1st. Count the numbers of cards facing up and their positions.

1 # include <iostream> 2 using namespace std; 3 int a [1001]; // 0 front up 4 void f (int n) 5 {6 if (n = 53) 7 return; 8 else 9 {10 for (int I = 1; I <= 52; I ++) 11 {12 if (I % n = 0) 13 {14 if (a [I] = 0) 15 a [I] = 1; 16 else a [I] = 0; 17} 18} 19 f (n + 1); 20} 21} 22 int main () 23 {24 f (2); 25 int tot = 0; 26 for (int I = 1; I <= 52; I ++) 27 {28 if (a [I] = 0) 29 {30 tot ++; 31 cout <I <"; 32} 33} 34 cout <endl; 35 cout <tot; 36 return 0; 37}

 

Related Article

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.