首页 > 试题广场 >

还是A+B

[编程题]还是A+B
  • 热度指数:6711 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
读入两个小于10000的正整数A和B,计算A+B。需要注意的是:如果A和B的末尾K(不超过8)位数字相同,请直接输出-1。

输入描述:
测试输入包含若干测试用例,每个测试用例占一行,格式为"A B K",相邻两数字有一个空格间隔。当A和B同时为0时输入结束,相应的结果不要输出。


输出描述:
对每个测试用例输出1行,即A+B的值或者是-1。
示例1

输入

1 2 1
11 21 1
108 8 2
36 64 3
0 0 1

输出

3
-1
-1
100
头像 在发论文的鲸鱼很刻苦
发表于 2023-03-04 00:32:36
#include <iostream> using namespace std; bool check(int a, int b, int k) { while (k--) { int end_a = a % 10;//取末尾数字 int end 展开全文
头像 鱼儿恋上水
发表于 2020-03-29 19:48:24
#include <iostream> #include <cstdio> #include <cmath> using namespace std; int main(){ int A, B, K; while(~scanf("%d %d %d" 展开全文
头像 笑川不吃香菜
发表于 2024-03-15 14:44:52
#include <iostream> using namespace std; int main() { int a, b,k; while (cin >> a >> b>>k) { // 注意 while 处理多个 case 展开全文
头像 爱吃的懒羊羊离上岸不远了
发表于 2025-03-10 11:32:46
#include <iostream> #include <algorithm> #include <cstring> #include <cmath> #include <iterator> #include <string> 展开全文
头像 牛客892605956号
发表于 2024-03-22 23:49:30
#include <iostream> using namespace std; int main() { int a, b, k; while (cin >> a >> b >> k && a && 展开全文
头像 arn
发表于 2023-03-02 15:16:54
import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { // TODO 自动生成 展开全文
头像 机试秒杀者
发表于 2025-03-17 19:45:16
#include<bits/stdc++.h> using namespace std; int main() { int k,l; int c; while(cin>>k>>l>>c) { if(k 展开全文
头像 Brillianman
发表于 2023-02-12 21:21:43
#include <stdbool.h> #include <stdint.h> #include<stdio.h> bool f(int A,int B,int K) { int i; for(i=0;i<K;i++) { 展开全文
头像 尤姆
发表于 2023-03-02 16:06:23
#include<cstdio> int main(){ int a, b, k; while (scanf("%d %d %d", &a, &b, &k) != EOF){ if (a == 0&&b==0){ break; } int x = a, y = b, 展开全文
头像 coder_bai
发表于 2023-03-21 02:18:56
#include<stdlib.h> #include<stdio.h> #include<algorithm> #include<iostream> #include<stack> #include<map> #include 展开全文

问题信息

难度:
66条回答 9278浏览

热门推荐

通过挑战的用户

查看代码
还是A+B