29 条题解

  • 36
    @ 2022-6-8 17:22:36

    这题主要考察int数据范围和long long 的数据范围

    数据类型直接定义成long long 就可以啦!

    int main()
    {
        long long  a,b; 
    
        return 0;
    }
    

    请看下图,因为题目$a,b$的范围到了$10^{8}$,$10^8*10^8$最多可能是$10^{16}$导致超出了int的存储范围,因此我们需要改为 long long,注意long之间有空格。

    或者就使用level4学习的字符串来处理这个问题

    今后做题务必关注数据范围,如果超过21092*10^9就超过了int,需要用long long,当然long long也只能使用不超过约910189*10^{18}左右的,如需更大的范围可以使用字符串或者高精度算法或者使用python

    基础数据类型的大小

    常见数据类型

    数据类型名 内容(一般情况) 占用内存大小 能储存的范围 scanf/printf 标识符(g++)
    int/signed 32 位整数 4 Bytes 2×1092×109-2\times 10^9\sim 2\times 10^9 %d/%d
    long long 64 位整数 8 Bytes 9×10189×1018-9\times 10^{18}\sim 9\times 10^{18} %lld/%lld
    char 字符 1 Byte 至少能储存 01270\sim 127
    常见范围为 128127-128\sim 127
    %c/%c
    float 单精度浮点数 4 Bytes 3.4×10383.4×1038-3.4\times 10^{38}\sim 3.4\times 10^{38}
    有效数字 676\sim 7
    %f/%f
    double 双精度浮点数 8 Bytes 1.7×103081.7×10308-1.7\times 10^{308}\sim 1.7\times 10^{308}
    有效数字 151615\sim 16 位$
    %lf/%f

    无符号整型

    数据类型名 内容(一般情况) 占用内存大小 能储存的范围 scanf/printf 标识符(g++)
    unsigned int 无符号 32 位整数 4 Bytes 023210 \sim 2^{32}-1
    04×1090 \sim 4\times 10^9
    %u/%u
    unsigned long long 无符号 64 位整数 8 Bytes 026410 \sim 2^{64}-1
    01.8×10190 \sim 1.8\times 10^{19}
    %llu/%llu
  • 31
    @ 2022-8-12 21:43:04

    我刚进入题解,刚想写,就看见了MOD的长篇大论,我很佩服他呀,牛牛牛,好了,这题的思路也总结好了,如下(以后重复的点我就不多说了哈,比如保留小数位数)

    1. 因为这次的 a 和 b 的值比较大所以我们需要用 long long 的形式来存储变量
    2. 然后就是输出啦,讲 a * b 输出即可,因为 long long 形式乘上 long long 形式还是 long long 形式

    好了,上代码吧!(最短)

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        long long a, b;
        cin >> a >> b;
        cout << a * b;
        return 0;
    }
    
    • @ 2022-8-21 15:29:13

      额老师嘛

    • @ 2022-8-27 13:13:44

      666👍 👍 👍

    • @ 2022-8-27 13:14:04

      ???@

    • @ 2022-8-31 19:01:59

      啊团长你就是歌姬吧

    • @ 2022-9-12 14:01:05

      嘻嘻,我更想用高精度

    • @ 2022-10-23 20:23:30
      #include <bits/stdc++.h>
      using namespace std;
      
      int main()
      {
      //  freopen(" .in", "r", stdin);
      //  freopen(" .out", "w", stdout);
          long long a, b;
          cin >> a >> b, cout << a * b;
          return 0;
      }
      
    • @ 2024-2-5 12:11:01

      666

  • 4
    @ 2023-11-13 9:15:11

    这道题简单,只要把定义类型改为long long就行了,请看题解(已AC,请放心食用😎

    #include <iostream>
    using namespace std;
    int main()
    {
        long long a, b;
        cin >> a >> b;
        cout << a * b;
        return 0;
    }
    

    看都看了,点个赞吧~ 谢谢!

    image

    • @ 2024-2-12 14:48:57

      66666666666666666666666666666666666666666666666666666666666666666666

    • @ 2024-2-12 14:49:48

      66666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666

    • @ 2024-2-12 14:50:35

      太好了

  • 4
    @ 2022-12-25 13:22:30
    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        long long a, b;
        cin >> a >> b;
        cout << a * b;
        return 0;
    }
    
    • 3
      @ 2023-8-27 18:19:40

      Python依旧一行稳定发挥

      print(next(map(lambda s: s[0] * s[1], [list(map(int, input().split()))])))
      

      可读性为0

      • 3
        @ 2023-8-20 18:51:35

        撒个鸡汤,这个大范围适应

        #include <bits/stdc++.h>//好习惯
        using namespace std;
        int main()
        {
            long long a, b;
            while (cin >> a >> b)
                cout << a * b;
            return 0;//好习惯
        }
        
        • @ 2023-8-20 18:54:47

          这种适应范围小些

          #include <bits/stdc++.h>//好习惯
          using namespace std;
          int main()
          {
              long long a, b;
              cin >> a >> b;
              cout << a * b;
              return 0;//好习惯
          }
          
      • 3
        @ 2023-8-15 20:07:32
        #include <bits/stdc++.h> 
        using namespace std;
        int main()
        {
            long long a,b;
            cin>>a>>b;
            cout<<a*b;
            return 0;
        }
        
        # 简单!
        
        • 3
          @ 2023-6-30 18:35:16
          #include <bits/stdc++.h>
          using namespace std;
          int main()
          {
              long long a, b;
              cin >> a >> b;
              cout << a * b;
              return 0;
          }
          我的最短代码之一
          
          • 3
            @ 2023-1-10 18:30:17
            #include<iostream>
            using namespace std;
            int main()
            {
                int long long a , b;
                cin >> a >> b;
                cout << a * b;
                return 0;
            }
            

            以AC请放心食用

            • 2
              @ 2023-8-16 8:00:23
              #include <iostream>
              using namespace std;
              int main(){
                  long long a , b;
                  cin >> a >> b;
                  cout << a * b;
                  return 0;
              }
              
              • 2
                @ 2023-4-29 20:43:20
                #include <bits/stdc++.h>
                using namespace std;
                int main()
                {
                    long long a,b;
                    cin >> a >> b;
                    cout << a*b;
                    return 0;
                }
                
                • 2
                  @ 2023-3-29 20:14:50
                  #include<bits/stdc++.h>
                  using namespace std;
                  int main()
                  {
                      long long a,b;
                      cin>>a>>b;
                      cout<<a*b;
                      return 0;
                  }
                  
                  • 2
                    @ 2023-1-25 16:52:49
                    #include <bits/stdc++.h>
                    using namespace std;int main(){long a,b;cin>>a>>b;cout<<a*b;return 0;}
                    
                    • @ 2024-2-2 17:03:25
                      #include<iostream>using namespace std;int main(){long long a,b;cin>>a>>b;cout<<a*b;}
                      
                  • 1
                    @ 2024-5-12 15:28:30
                    #include <bits/stdc++.h>
                    using namespace std;
                    int main()
                    {
                        long long a,b;//比较大的数用long long
                        cin >> a >> b;
                        cout << a*b;
                        return 0;
                    }
                    
                    • 1
                      @ 2022-12-14 18:34:23

                      太简单了,只需要搞清楚数据类型就行了

                      #include <iostream>
                      using namespace std;
                      int main(){
                          long long a, b;
                          cin >> a >> b;
                          cout << a * b;
                          return 0;
                      }
                      
                      • 0
                        @ 2024-2-14 17:35:59
                        #include <iostream>
                        using namespace std;
                        int main()
                        {
                            long long a,b,c;//为了减少代码行数,我把a,b,c都设成了long long类型
                            cin >> a >> b;
                            c=a*b;//乘法运算大家应该都会
                            cout << c;//上过核桃编程C++的人都懂
                            return 0;
                        }
                        

                        就是这么的JD!(简单)

                        • 0
                          @ 2024-1-24 12:32:47
                          #include <iostream>
                          using namespace std;
                          int main ()
                          {
                              long long a,b;
                              cin >> a >> b;
                              cout << a*b;
                              return 0;
                          }
                          

                          更适合中国宝宝体质的~奶粉~代码,简单易懂👀️ 蒙着眼睛都能做对……(要copy的吱一声哈)

                          • 0
                            @ 2024-1-2 21:27:04

                            #include <bits/stdc++.h> using namespace std; int main() {long long a,b; cin >> a >> b; cout << a*b;}

                            • 0
                              @ 2023-9-11 21:38:57

                              #include<bits/stdc++.h> #define N 200005 using namespace std; long long i=0,j=0; void app(){ string str1,str2; int a[N]={0},b[N]={0},c[N*2]={0},len1,len2,len3; cin >> str1 >> str2; len1= str1.size(); len2= str2.size(); len3= len1+len2; for(i=0;i<len1;i++) a[len1-i-1] = str1[i]-'0'; for(i=0;i<len2;i++) b[len2-i-1] = str2[i]-'0'; for(i=0;i<len1;i++){ for(j=0;j<len2;j++) c[i+j]+=a[i]*b[j]; } int x=0; for(i=0;i<len3;i++) c[i]=c[i]+x,x=c[i]/10,c[i]=c[i]%10; while(c[len3]==0&&len3>0) len3--; for(int i=len3;i>=0;i--) printf("%d",c[i]); return ; } int main(){ app(); return 0; }

                              • 0
                                @ 2023-8-15 13:08:37
                                #include <iostream>
                                using namespace std;
                                int main()
                                {
                                    long a,b;
                                	cin>>a>>b;
                                	cout<<long(a*b);
                                	return 0; 
                                }
                                //依旧两种写法
                                

                                #include <bits/stdc++.h> using namespace std; int main() { long long a, b; cin >> a >> b; cout << a * b; return 0; } //两种方法都赞成 //老规矩不用❤️ 😄 //均以AC,0.0s过

                                
                                

                              信息

                              ID
                              1795
                              时间
                              1000ms
                              内存
                              256MiB
                              难度
                              3
                              标签
                              递交数
                              2920
                              已通过
                              1631
                              上传者