Ultraviolet A 11490

Source: Internet
Author: User

11490-Just Another Problem

Question Link

There are S soldiers in a matrix. There can be two holes in the matrix. The thickness of the two holes is the same between the top and bottom, and the number of soldiers is missing.

Idea: Push the formula, set the thickness to a and the square to I, then (3 a + 2 I) (2 a + I) = S + 2 I;
6 I + 7 a I = S.
Due to the large size of S, it is enough to enumerate the thickness of sqrt (S), and the complexity is acceptable.

Code:

# Include <stdio. h> # include <string. h> # include <math. h> const long MOD = 100000007; long n; int main () {while (~ Scanf ("% lld", & n) {int flag = 1; for (long I = 1; I * 6 <n; I ++) {long tmp = n-I * 6; if (tmp % (7 * I) = 0) {long ans = tmp/(7 * I) % MOD; printf ("Possible Missing Soldiers = % lld \ n", ans * 2% MOD); flag = 0 ;}} if (flag) printf ("No Solution Possible \ n"); printf ("\ n");} 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.