每日一九度之 题目1083:特殊乘法

时间限制:1 秒

内存限制:32 兆

特殊判题:

提交:5319

解决:3606

题目描述:

写个算法,对2个小于1000000000的输入,求结果。

特殊乘法举例:123 * 45 = 1*4 +1*5 +2*4 +2*5 +3*4+3*5

输入:

 两个小于1000000000的数

输出:

 输入可能有多组数据,对于每一组数据,输出Input中的两个数按照题目要求的方法进行运算后得到的结果。

样例输入:
123 45
样例输出:
54

按题目直接模拟就好。

复制代码
//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;
}
复制代码

 

posted @   Asimple  阅读(254)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
点击右上角即可分享
微信分享提示