Codeforces #262 DIV2 B Question Little Dima and Equation,

Source: Internet
Author: User

Codeforces #262 DIV2 B Question Little Dima and Equation,

Address: http://codeforces.com/contest/460/problem/ B

There is no idea at first glance, but after careful analysis, we will find that s (x) is a number ranging from 1 to 81, No matter what x is. Therefore, we can enumerate 1 to 81, which is converted into a one-dimensional equation. Then we can solve x directly. At this time, we need to determine whether x is between 1 and 10 ^ 9, and the sum of all its numbers is s (x ).

This question has left my head dead twice... The first time is written as <= 10 ^ 9 .. After finding the error, I changed it back .. But it is impossible to find 10 ^ 9 ,....

The Code is as follows:

#include <iostream>#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>#include <ctype.h>#include <algorithm>#include <queue>using namespace std;#define LL __int64LL aa[100];int main(){    LL n, a, b, c, ans=0, i, y, zz, j;    LL x, z;    scanf("%I64d%I64d%I64d",&a,&b,&c);    for(i=1;i<=81;i++)    {        zz=1;        for(j=1;j<=a;j++)            zz*=i;        x=zz*b+c;        y=0;        z=x;        while(z)        {            y+=z%10;            z/=10;        }        if(y==i&&x>=1&&x<1e9)        {            aa[ans++]=x;        }    }    printf("%I64d\n",ans);    for(i=0;i<ans;i++)    {        printf("%I64d ",aa[i]);    }    return 0;}



Codeforces question: How can I attack others in codeforces?

For a question, you must first pass TEST. Then return to the PROBLEM list of the game, lock the lock behind the question (the lock won't be submitted again, so don't lock it if you're unsure), and then go to the ROOM, you can check other people's Code. There is a HACK button below. Click it and enter the example that you think is wrong.

How to view test data on codeforces

Enter the competition, click my submissions, and then click the RUN number under # To view the test data.

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.