27: divided by 13, 27 divided by 13

Source: Internet
Author: User
Tags integer division

27: divided by 13, 27 divided by 13
27: divided by 13

  • View
  • Submit
  • Statistics
  • Question
Total time limit:
1000 ms
 
Memory limit:
65536kB
Description

Enter a large integer N greater than 0, with a length of no more than 100 characters. divide it by 13 to get the quotient and remainder.

Input
A large integer greater than 0 with a length of no more than 100 characters.
Output
The two rows are the quotient and remainder obtained by integer division.
Sample Input
2132104848488485
Sample output
1640080652683450
Prompt
In a simulated division operation, the quotient length should be 1 or 2 less than the length of the input large integer.
Source
Exercise (12-11)
1 # include <iostream> 2 # include <cstdio> 3 # include <cstring> 4 using namespace std; 5 char a1 [10001]; 6 int a [10001]; 7 int c [10001]; 8 int main () 9 {10 gets (a1); 11 int la = strlen (a1); 12 for (int I = 0; I <la; I ++) 13 {14 a [I + 1] = a1 [I]-48; 15} 16 int x = 0; // vendor 17 for (int I = 1; I <= la; I ++) 18 {19 c [I] = (x * 10 + a [I]) /13; 20 x = (x * 10 + a [I]) % 13; 21} 22 int lc = 1; 23 for (int I = 1; I <= la; I ++) 24 {25 if (c [I] = 0 & lc <la) 26 lc ++; 27 else break; 28} 29 for (int I = lc; I <= la; I ++) 30 cout <c [I]; 31 cout <endl; 32 cout <x; 33 return 0; 34}

 

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.