The remainder of nine

Source: Internet
Author: User

Remainder time limit of nine: theMs | Memory Limit:65535KB Difficulty:3
Describe

Now give you a natural number n, whose number is less than or equal to 1 million, now all you have to do is find the remainder after the number is divisible by nine.

Input
the first line has an integer m (1<=m<=8), which indicates that there is an M-group of test data;
The M row then has a natural number n per row.
Output
output n is divided by the remainder after nine, with each output occupying one row.
Sample input
345465456541
Sample output
454
Source
[Miao Building] Original
Uploaded by

Miao-dong Building

Review the division of large numbers ~ ~

#include <iostream> #include <stdio.h> #include <string.h>using namespace Std;char a[1000000];int Main () {int T,yushu,len,i,s;cin>>t;while (t--) {yushu=0;        cin>>a;        Len=strlen (a);       for (i=0;i<len;i++)   {   s=yushu*10+ (a[i]-' 0 ');   yushu=s%9;   }   Cout<<yushu<<endl;} return 0;}        

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The remainder of nine

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.