1082 and 7 unrelated numbers

Source: Internet
Author: User

1082 and 7 unrelated numbers

Base time limit: 1 seconds Space limit: 131072 kb A positive integer, if it can be divisible by 7, or its decimal notation in a single digit number is 7, it is said to be the number associated with 7. The sum of the squares of all positive integers that are less than or equal to N and 7 independent. For example: N = 8,<= 8 and 7 are unrelated to the number including: 1 2 3 4 5 6 8, squared sum is: 155. Input
Line 1th: A number t that represents the number of numbers that are later used as input tests. (1 <= T <= 1000) 2-t + 1 lines: 1 number n per line. (1 <= N <= 10^6)
Output
A total of T-lines, one number per line, corresponding to the results of the T test.
Input example
545678
Output example
30559191155
//play the table;#include <cstdio>#defineN 1000000typedefLong LongLL; LL Sb[n+10000];voidsieve () { for(intI=1; i<=n+ -; i++)    {        if(i%7!=0)        {            intq=i; BOOLflag=0;  while(Q) {intR= q%Ten; if(r==7) {flag=1;  Break; } Q/=Ten; }            if(flag==1) Sb[i]=sb[i-1]; if(flag==0) Sb[i]=sb[i-1]+ (LL) i*i; }        ElseSb[i]= sb[i-1]; }}intMain () {sieve (); intT; scanf ("%d", &t);  while(t--)    {        intN; scanf ("%d", &N); printf ("%lld\n", Sb[n]); }    return 0;}

1082 and 7 unrelated numbers

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.