當(dāng)前位置:
首頁 >
每日一九度之 题目1083:特殊乘法
發(fā)布時(shí)間:2025/4/14
39
豆豆
生活随笔
收集整理的這篇文章主要介紹了
每日一九度之 题目1083:特殊乘法
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
時(shí)間限制:1 秒
內(nèi)存限制:32 兆
特殊判題:否
提交:5319
解決:3606
題目描述:寫個(gè)算法,對2個(gè)小于1000000000的輸入,求結(jié)果。
特殊乘法舉例:123 * 45 = 1*4 +1*5 +2*4 +2*5 +3*4+3*5
?兩個(gè)小于1000000000的數(shù)
?輸入可能有多組數(shù)據(jù),對于每一組數(shù)據(jù),輸出Input中的兩個(gè)數(shù)按照題目要求的方法進(jìn)行運(yùn)算后得到的結(jié)果。
按題目直接模擬就好。
//Asimple #include <iostream> #include <algorithm> #include <cstring> #include <cstdio> #include <vector> #include <cctype> #include <cstdlib> #include <stack> #include <cmath> #include <set> #include <map> #include <string> #include <queue> #include <limits.h> #define INF 0x7fffffff using namespace std; const int maxn = 55; typedef long long ll; ll sum = 0; char s1[maxn], s2[maxn];int main(){while( ~scanf("%s %s",s1, s2) ){sum =0;for(int i=0; s1[i]!='\0'; i++){for(int j=0; s2[j]!='\0'; j++){sum += (s1[i]-'0')*(s2[j]-'0');}}printf("%ld\n",sum);}return 0; }?
轉(zhuǎn)載于:https://www.cnblogs.com/Asimple/p/5965301.html
總結(jié)
以上是生活随笔為你收集整理的每日一九度之 题目1083:特殊乘法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: jQuery+css模拟下拉框模糊搜索的
- 下一篇: Shell until循环