1022 D進制的A+B (20)(20 分)
2018-07-28 20:24:39
輸入兩個非負10進制整數A和B(<=2^30^-1),輸出A+B的D (1 < D <= 10)進制數。
輸入格式:
輸入在一行中依次給出3個整數A、B和D。
輸出格式:
輸出A+B的D進制數。
輸入樣例:
123 456 8
輸出樣例:
1103
#include<stdio.h> int main(){ int a,b,d,sum,j; int i=0; int s[31]={0}; //此處犯得錯誤是數組的名稱不能和你所定義的變量名相同 scanf("%d%d%d",&a,&b,&d); sum=a+b; if(sum==0)printf("0\n"); while(sum>0){ s[i++]=sum%d; sum/=d; } for(j=i-1;j>=0;j--){ printf("%d",s[j]); } return 0; }
1022 D進制的A+B (20)(20 分)
相關推薦
1022 D進制的A+B (20)(20 分)
color %d a+b while 格式 stdio.h for 輸入 sca 2018-07-28 20:24:39 輸入兩個非負10進制整數A和B(<=2^30^-1),輸出A+B的D (1 < D <= 10)進制數。 輸入格式: 輸入在一行中依次
PAT乙級1022.D進制的A+B(20 分)
include ios tom set nbsp mes a+b fontsize -o 1022 D進制的A+B(20 分) 輸入兩個非負 10 進制整數 A 和 B (≤2?30??−1),輸出 A+B 的 D (1<D≤10
1022 D進制的A+B (20 分)
tex -i sin minus int scripts itl name 代碼 1022 D進制的A+B (20 分) 輸入兩個非負 10 進制整數 A 和 B (≤2?30??−1),輸出 A+B 的 D (1<D≤10)進制
1022 D進制的A+B
math light stream int != 進制數 ram main base 輸入兩個非負 10 進制整數 A 和 B (≤),輸出 A+B 的 D (1)進制數。 輸入格式: 輸入在一行中依次給出 3 個整數 A、B 和 D。 輸出格式: 輸出 A+
BZOJ3107 CQOI2013二進制A+B(動態規劃)
mes pan main name 一位 tchar for 答案 str 顯然答案只與a、b、c中各自1的個數及位數有關。a、b只考慮前i位怎麽填時,c最多在第i+1位上為1,而第i+1位及之後的a、b怎麽填都不會對前i位造成影響。於是設f[n][i][j][k][0
P4574 [CQOI2013]二進制A+B
1的個數 最小值 amp bsp blank code ring spa can P4574 [CQOI2013]二進制A+B 數位dp 設f[ i ][ a ][ b ][ c ][ 0/1 ]表示在第 i 位,A、B、C各貢獻了a、b、c個1,是否需要進位的情況下,
BZOJ 3107 [cqoi2013]二進制a+b (DP)
scan cpp typedef min [1] 整數 mem clr lld 3107: [cqoi2013]二進制a+b Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 995 Solved: 444[Submit][
PAT (Advanced level) 1001 A+B Format (20 分)
1001 A+B Format (20 分) Calculate a+b and output the sum in standard format – that is, the digits must be separated into groups of three by com
PAT (Advanced Level) Practice 1001 A+B Format (20 分)
Calculate a+b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there
PAT (Advanced Level) Practice 1001 A+B Format (20 分)(C++)(甲級)
1001 A+B Format (20 分) Calculate a+b and output the sum in standard format – that is, the digits must be separated into groups of three by com
1001 A+B Format (20 分)
reverse integer uno calculate sum span tst all ins 1001 A+B Format (20 分) Calculate a+b and output the sum in standard format -- that
P1832 A+B Problem(再升級)
using 輸出格式 algorithm 一行 題目 -a scanf 問題 mes P1832 A+B Problem(再升級) 題目背景 ·題目名稱是吸引你點進來的 ·實際上該題還是很水的 題目描述 ·1+1=? 顯然是2 ·a+b=? 1001回看不謝 ·哥德巴赫猜想
洛谷 P1581 A+B Problem(升級版)
就是 reg 一個 ack left void 輸出 思路 bad P1581 A+B Problem(升級版) 題目背景 小明這在寫作業,其中有一道A+B Problem ,他想啊想啊想,就是想不出來,於是就找到了會編程的你......
完全背包【p1832】A+B Problem(再升級)
spa 枚舉 iostream fin break oid getchar() true += Description 給定一個正整數n,求將其分解成若幹個素數之和的方案總數。 Input 一行:一個正整數n Output 一行:一個整數表示方案總數 素數之和 ? 背包
a^b問題(南陽oj473)
A^B Problem 時間限制:1000 ms | 記憶體限制:65535 KB 難度:2 描述 Give you two numbers a and b,how to know the a^b's the last digit number.It look
【洛谷 1601】A+B Problem(高精)
問題描述 高精度加法(無負數) 樣例輸入 1 1 樣例輸出 2 const maxn=100; var a,b:array[1..maxn] of longint; proce
A+B Problem (程式入門)
題目描述 Calculate a+b 輸入 Two integer a,b (0<=a,b<=10) 輸出 Output a+b 樣例輸入 1 2 樣例輸出 3 //
PAT 1097 Deduplication on a Linked List(25 分)
Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, f
PAT (Advanced Level) Practice 1102 Invert a Binary Tree (25 分)樹的遍歷
The following is from Max Howell @twitter: Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary tree on
PAT 1102 Invert a Binary Tree (25 分)
1102 Invert a Binary Tree (25 分) The following is from Max Howell @twitter: Google: 90% of our engineers use the software you wrote (Homebrew)