87 条题解

  • 61
    @ 2022-9-10 19:57:10

    这道题一如既往的简单
    定义
    输入
    判断(是否要加一)并输出

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int a;
        cin >> a;
        int b = a / 8;
        if (a % 8 != 0) b ++;
        cout << b << endl;
    	re turn 0; 
    }
    

    小盆友们,您学会了吗?

    复制? 代码不易,先点赞,再复制吧! (不要忘了删倒数第二行的空格!)

    • @ 2023-3-4 9:13:33

      return 0;

    • @ 2023-8-10 19:33:31

      @ 也可以不写

    • @ 2023-8-11 18:17:46

      我真服啦,一直错1个(我自己的代码) 感谢解惑

    • @ 2023-8-12 16:19:14

      😄

      {"messages":{},"UiContext":{"cdn_prefix":"/","url_prefix":"/","ws_prefix":"/","nav_logo_dark":"http://oj.hetao101.com/d/cpp_teacher/file/106/55.png","constantVersion":"e6b2fad1","domainId":"training","domain":{"_id":"training","lower":"training","owner":2,"name":"练习题库","bulletin":"# 核OJ_核桃编程 - 练习题库\r\n\r\n[⇐ 返回根题库](http://oj.hetao101.com/)\r\n\r\n## 基本使用方法\r\n\r\nP 系列题目来自网络,可能会有题目排版数据问题,部分纯输出的题目可能缺少数据,管理员看到缺少数据系统错误的提交后会及时修复。遇到问题可以在讨论区发布帖子。\r\n\r\n1. 通过题库点击某道想做的题目\r\n2. 读题\r\n3. 点击进入在线编程模式\r\n4. 点击右上方的自测打开自测窗口\r\n5. 将题目的样例输入复制进输入框中\r\n6. 点击运行自测,查看是否与输出一致\r\n7. 如果结果没有问题,可以点击递交评测查看评测结果\r\n8. 如果显示错误、可以对应地修改代码再次自测\r\n\r\n![](http://oj.hetao101.com/file/2/t.png)\r\n\r\n## 常见设置\r\n\r\n0. 设置当前题库的显示名:<http://oj.hetao101.com/d/training/home/settings/domain>\r\n1. 进入当前题库的偏好设置页面:<http://oj.hetao101.com/d/training/home/settings/preference>\r\n2. 将显示偏好中的**用户界面语言**设置成**简体中文**\r\n3. 将使用偏好中的**代码语言**设置成自己常用的语言\r\n4. 将使用偏好中的**默认代码模板**改成自己习惯的代码框架,比如下面这段\r\n\r\n```cpp\r\n#include<bits/stdc++.h>\r\nusing namespace std;\r\nint main(){\r\n\r\n\r\n\r\n    return 0;\r\n}\r\n```\r\n","roles":{"3":"10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376","teacher":"10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652777725396788478736373","guest":"10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624967874125500547201","default":"10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652777525100954235143873","root":"-1","cpp":"10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652789254612192640104439","contest_creator":"10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652777526956929862828997","new_teacher":"10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652777543124148872280005"},"avatar":"url:https://ecmb.bdimg.com/tam-ogel/1969563307_-1467192127_88_88.jpg","langs":"cc.std98,cc.std11,cc.std14,py.py3,cc,py","share":"*"},"SWConfig":{"preload":"","hosts":["http://oj.hetao101.com","https://oj.hetao101.com","oj.hetao101.com/","/"],"domains":[]}},"UserContext":"{\"_id\":17475,\"mail\":\"5976915@hetao101.com\",\"uname\":\"hetao5976915\",\"hashType\":\"hydro\",\"priv\":16842756,\"regat\":\"2023-07-12T06:13:59.355Z\",\"loginat\":\"2023-08-01T11:27:44.933Z\",\"perm\":\"BigInt::10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652777525100954235143873\",\"scope\":\"BigInt::-1\",\"role\":\"default\",\"domains\":[],\"tfa\":false,\"authn\":false,\"group\":[\"17475\"],\"timeZone\":\"Asia/Shanghai\",\"codeLang\":\"cc\",\"avatar\":\"gravatar:5976915@hetao101.com\",\"gender\":2,\"backgroundImage\":\"/components/profile/backgrounds/1.jpg\",\"unreadMsg\":0,\"pinnedDomains\":[],\"fontFamily\":\"Open Sans\",\"codeFontFamily\":\"Source Code Pro\",\"preferredEditorType\":\"sv\",\"monacoTheme\":\"vs-light\",\"theme\":\"light\",\"formatCode\":true,\"nAccept\":9,\"nSubmit\":23,\"rp\":5,\"rpInfo\":{\"problem\":5},\"rank\":5740,\"level\":1,\"avatarUrl\":\"//cn.gravatar.com/avatar/dc51bdcf0c080f7680e4d1069ddde2a2?d=mm&s=128\"}"}
      瞧瞧
      
    • @ 2023-8-12 16:22:06

      @Maomao

    • @ 2023-8-15 15:29:53

      👍 👍 👍

    • @ 2023-10-1 11:02:54

      @ #include<bits/stdc++.h> using namespace std; int main() { int a; cin >> a; int b = a / 8; if (a % 8 != 0) b ++; cout << b << endl; return 0; }

    • @ 2024-2-22 11:36:19

      有一个地方错了,不知道你们看出来没

  • 19
    @ 2022-7-8 16:21:11

    if else搞定:

    #include <iostream>
    using namespace std;
    int main()
    {
        int n;
        cin >>n;
        //定义+输入
        if (n%8==0)
        {
            cout <<n/8;
        }
        else
        {
            cout <<n/8+1;
        }
        // 判断
        return 0;
    }
    
  • 11
    @ 2023-6-14 18:01:00

    这道题不是编程题image!,这道题是赤裸裸的数学应用题image,欺负的是正在学习有余数除法的弟弟妹妹们!*

    老是忘记加一!!

    #include <iostream> 
    using namespace std;
    int main()
    {
        int n;
        cin >> n;
        cout << n / 8 + (n % 8 == 0 ? 0 : 1); //三目运算符,if太难打(问号前面成立就返回 :前面的, 否则返回 : 后面的)。
        return 0;
    }
    

    C++小萌新,多包容!! 欢迎复制, 编码不易, 一定得image

    点赞!!

    • @ 2023-7-24 15:49:29

      好奇你是怎么整出来动态表情包的[狗头]

    • @ 2023-8-12 16:36:35

      😄

      {"messages":{},"UiContext":{"cdn_prefix":"/","url_prefix":"/","ws_prefix":"/","nav_logo_dark":"http://oj.hetao101.com/d/cpp_teacher/file/106/55.png","constantVersion":"e6b2fad1","domainId":"training","domain":{"_id":"training","lower":"training","owner":2,"name":"练习题库","bulletin":"# 核OJ_核桃编程 - 练习题库\r\n\r\n[⇐ 返回根题库](http://oj.hetao101.com/)\r\n\r\n## 基本使用方法\r\n\r\nP 系列题目来自网络,可能会有题目排版数据问题,部分纯输出的题目可能缺少数据,管理员看到缺少数据系统错误的提交后会及时修复。遇到问题可以在讨论区发布帖子。\r\n\r\n1. 通过题库点击某道想做的题目\r\n2. 读题\r\n3. 点击进入在线编程模式\r\n4. 点击右上方的自测打开自测窗口\r\n5. 将题目的样例输入复制进输入框中\r\n6. 点击运行自测,查看是否与输出一致\r\n7. 如果结果没有问题,可以点击递交评测查看评测结果\r\n8. 如果显示错误、可以对应地修改代码再次自测\r\n\r\n![](http://oj.hetao101.com/file/2/t.png)\r\n\r\n## 常见设置\r\n\r\n0. 设置当前题库的显示名:<http://oj.hetao101.com/d/training/home/settings/domain>\r\n1. 进入当前题库的偏好设置页面:<http://oj.hetao101.com/d/training/home/settings/preference>\r\n2. 将显示偏好中的**用户界面语言**设置成**简体中文**\r\n3. 将使用偏好中的**代码语言**设置成自己常用的语言\r\n4. 将使用偏好中的**默认代码模板**改成自己习惯的代码框架,比如下面这段\r\n\r\n```cpp\r\n#include<bits/stdc++.h>\r\nusing namespace std;\r\nint main(){\r\n\r\n\r\n\r\n    return 0;\r\n}\r\n```\r\n","roles":{"3":"10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376","teacher":"10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652777725396788478736373","guest":"10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624967874125500547201","default":"10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652777525100954235143873","root":"-1","cpp":"10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652789254612192640104439","contest_creator":"10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652777526956929862828997","new_teacher":"10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652777543124148872280005"},"avatar":"url:https://ecmb.bdimg.com/tam-ogel/1969563307_-1467192127_88_88.jpg","langs":"cc.std98,cc.std11,cc.std14,py.py3,cc,py","share":"*"},"SWConfig":{"preload":"","hosts":["http://oj.hetao101.com","https://oj.hetao101.com","oj.hetao101.com/","/"],"domains":[]}},"UserContext":"{\"_id\":17475,\"mail\":\"5976915@hetao101.com\",\"uname\":\"hetao5976915\",\"hashType\":\"hydro\",\"priv\":16842756,\"regat\":\"2023-07-12T06:13:59.355Z\",\"loginat\":\"2023-08-01T11:27:44.933Z\",\"perm\":\"BigInt::10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652777525100954235143873\",\"scope\":\"BigInt::-1\",\"role\":\"default\",\"domains\":[],\"tfa\":false,\"authn\":false,\"group\":[\"17475\"],\"timeZone\":\"Asia/Shanghai\",\"codeLang\":\"cc\",\"avatar\":\"gravatar:5976915@hetao101.com\",\"gender\":2,\"backgroundImage\":\"/components/profile/backgrounds/1.jpg\",\"unreadMsg\":0,\"pinnedDomains\":[],\"fontFamily\":\"Open Sans\",\"codeFontFamily\":\"Source Code Pro\",\"preferredEditorType\":\"sv\",\"monacoTheme\":\"vs-light\",\"theme\":\"light\",\"formatCode\":true,\"nAccept\":9,\"nSubmit\":23,\"rp\":5,\"rpInfo\":{\"problem\":5},\"rank\":5740,\"level\":1,\"avatarUrl\":\"//cn.gravatar.com/avatar/dc51bdcf0c080f7680e4d1069ddde2a2?d=mm&s=128\"}"}
      瞧瞧
      
    • @ 2023-8-16 12:18:47

      我槽牛哔

    • @ 2023-8-16 12:26:10

      我也是萌新

    • @ 2023-8-20 13:39:48

      网站源代码

    • @ 2023-8-28 10:34:34

      啊对对对

    • @ 2024-1-16 14:28:53

      也就是4年级以前的小盆友们

    • @ 2024-2-5 13:42:48

      if 太难打?

  • 7
    @ 2022-8-31 10:30:41
    #include<iostream>
    using namespace std;
    int main()
    {
        int n;
        cin>>n;
       if(n%8!=0)
       {
        cout<<n/8+1;
       }
       else
       {
       cout<<n/8;
       }
        return 0;
    }
    
    • 3
      @ 2023-8-17 22:02:29

      不会吧,这么简单 应该都会吧......(先 后看!养成习惯!)

      #include <iostream>
      //       瓦是不会告诉你有万能头文件这种东西的
      using namespace std;
      int main()
      {
          int a,sum;
          cin>>a;//输入a
          if(a%8==0)
          {
              cout<<a/8;
              //当正好时
          }
          else if(a%8!=0)
          {
              cout<<a/8+1;
              //当不足时
          }
          return 0;
      }
      

      制作不易,给个赞吧,球球了...... 有什么问题,联系我,邮箱是ASheepBoy_Bed@163.com

      • 1
        @ 2024-3-10 19:53:57
        #include<bits/stdc++.h>
        using namespace std;
        int main()
        {
            int a;
            cin >> a;
            int b = a / 8;
            if (a % 8 != 0) b ++;
            cout << b << endl;
        	return 0; 
        }
        
        • 0
          @ 2024-5-15 15:38:14

          image 我理解的是这样,但是这样写是判定错误的。但代码的输入与输出是一样的。

          • 0
            @ 2024-5-5 21:18:22

            写题解请注意

            鼓励大家写题解,但注意题解格式。

            题解一定要有思路解析或代码注释,能否让别人理解你的思路

            也是你的能力的检验,不要只放无意义的代码给大家复制,那就失去了做题的初心。

            给代码两端加上这个会舒服一些

            ```cpp

            你的代码

            ```

            </span>

            这个点在键盘的左上角tab上面那个键,注意切换输入法

            #include<iostream>
            using namespace std;
            int main()
            {
                int n;
                cin>>n;//这是一个注释
                return 0;
            }
            

            Copy

            请注意严禁抄袭题解,写题解不要只放代码,需加上你的思路或代码注释。

            题解最好只有核心代码的展示,而不是全代码,避免有同学复制你的代码,虽然我们也会核查提交记录。(老师使用万能的python脚本调取网页日志核查,当然不是一个个看了)

            抄袭题解一经发现直接取消成绩。

            题解被删除的可能

            1. 代码不符合格式规范
            2. 没有思路讲解或者没有注释,
            3. 无意义的题解
            4. 题解代码可以供他人直接复制,因此这里要求大家只放核心代码。例如一道for循环求和得题目,我们只需要写好for循环的关键代码即可,定义变量这些就不需要在教给大家了。

            大家携手共同维护一个良好的编程环境,如果一经发现,多次作乱。可能会被管理员拉黑,请注意,一旦拉黑即失去登陆资格。

            • 0
              @ 2024-4-2 21:58:38

              #include<bits/stdc++.h> using namespace std; int n; int main() { cin>>n; if(n%8!=0) cout<<n/8+1; else cout<<n/8; return 0; }

              • 0
                @ 2024-2-22 11:35:36

                简单 `

                #include <iostream>
                using namespace std;
                int main()
                {
                    int n,c;//n代表木柴数量,c代表次数。
                    cin>>n;
                    if(n%8==0)
                    {
                        c=n/8;
                    }
                    else
                    {
                        c=n/8+1;
                    }
                    cout<<c;
                    return 0;
                }
                
                • 0
                  @ 2024-1-31 14:00:49

                  点个赞吧😄

                  #include <bits/stdc++.h> 
                  using namespace std;
                  int main()
                  {
                      int a, sum = 0;
                      cin >> a;
                      sum = a / 8;
                      if (a % 8 != 0)//如果不足八根,总次数加1
                      {
                          sum++;
                      }
                      cout << sum;
                      return 0;
                  }
                  
                  • 0
                    @ 2024-1-28 22:01:01

                    直接上代码😄 :

                    #include <bits/stdc++.h> 
                    using namespace std;
                    int n;//n表示木柴的数量
                    int main()
                    {
                        cin>>n;//输入木柴的数量
                        //这其实是一道数学题,如果n÷8有余数,输出商+1,否则直接输出商
                        if(n%8!=0)//如果n÷8有余数
                        {
                            cout<<n/8+1;//输出商+1
                        }
                        else//否则,即无余数,可整除
                        {
                            cout<<n/8;//直接输出商
                        }
                        return 0;
                    }
                    

                    image

                    • 0
                      @ 2024-1-16 14:31:28

                      就数不一样,其它原题👀️

                      • 0
                        @ 2024-1-3 21:25:00
                        #include <iostream>
                        using namespace std;
                        int main()
                        {
                            int n,sum =0;
                            cin >> n;
                            sum = n / 8;
                            if (n % 8 != 0)
                            {
                                cout << sum+1 << endl;
                            }
                            else
                            {
                                cout << sum << endl;
                            }
                            return 0;
                        }
                        
                        • 0
                          @ 2024-1-2 23:00:43
                          #include <bits/stdc++.h`>
                          using namespace std;
                          int main()
                          {
                          int n,x;
                          double a;
                          cin >> n;
                          a=n/8.0;//这里要除以8.0,不然有问题
                          a+=0.9;
                          x=a;
                          cout << x;
                          return 0;
                          }
                          
                          • 0
                            @ 2023-9-4 19:49:07
                            #include<bits/stdc++.h>//万能开头
                            using namespace std;
                            int n,x;//x是最终答案
                            int main()
                            {
                                cin>>n;//输入变量
                                x=n/8;//能运满多少车
                                if (n%8>0) //有没有剩余
                                {
                                    x++;
                                }
                                cout<<x;//输出
                                return 0; 
                            }
                            
                            //一手交赞,一手交货(代码)
                             
                            
                            
                            
                            
                            //核桃hetao1609095编程
                            //水印
                            
                            • 0
                              @ 2023-9-3 21:48:20
                              #include <iostream>
                              using namespace std;
                              int main()
                              {
                                  int n;
                                  cin >> n;
                                  if (n % 8 == 0)
                                  {
                                      cout << n / 8;
                                  }
                                  else
                                  {
                                      cout << n / 8 + 1;
                                  }
                                  return 0;
                              }
                              //别复制
                              
                              • 0
                                @ 2023-8-31 16:36:23

                                #include <iostream> using namespace std; int main() { int a; cin>>a; if (a%8!=0) { cout<<a/8+1; } else { cout<<a/8; }

                                return 0;
                                

                                }

                                • 0
                                  @ 2023-8-29 18:14:16

                                  也是灰常简单好吧

                                  easy版:

                                  #include<iostream> //简单到不用写万能头文件~~
                                  using namespace std;
                                  int main(){
                                  	//读入n
                                  	int n;cin>>n;
                                  	//判断是否有余数 
                                  	if(n%8!=0){
                                  		//有则给整除结果+1 
                                  		cout<<n/8+1; 
                                  	}else{
                                  		//没有则直接输出 
                                  		cout<<n/8;
                                  	}
                                  	//return 0表示程序结束 
                                  	return 0;
                                  }
                                  

                                  高只因版:

                                  //因为scanf和printf的原因,所以要用万能头文件 
                                  #include<bits/stdc++.h>
                                  using namespace std;
                                  int main(){
                                  	//读入n
                                  	int n;
                                  	scanf("%d",&n);
                                  	//判断是否有余数 
                                  	if(n%8!=0){
                                  		//有则给整除结果+1 
                                  		printf("%d",n/8+1);
                                  	}else{
                                  		//没有则直接输出 
                                  		printf("%d",n/8);
                                  	}
                                  	//return 0表示程序结束
                                  	return 0;
                                  }
                                  

                                  AC版:

                                  #include <iostream> //简单到不用写万能头文件~~
                                  using namespace std;
                                  
                                  int main()
                                  {
                                  	//读入n
                                  	int n;
                                  	cin >> n;
                                  	//判断是否有余数 
                                  	if (n % 8 ! = 0)
                                  	{
                                  		//有则给整除结果+1 
                                  		cout << n / 8 + 1; 
                                  	}
                                  	else
                                  	{
                                  		//没有则直接输出 
                                  		cout << n / 8;
                                  	}
                                  	//return 0表示程序结束 
                                  	return 0;
                                  }
                                  
                                  • 0
                                    @ 2023-8-14 10:43:46
                                    #include <iostream>
                                    using namespace std;
                                    int main()
                                    {
                                        int a,m=0;
                                        cin >> a;
                                        if(a%8==0)
                                        {
                                            m=a/8;
                                        }
                                        else
                                        {
                                            m=a/8+1;//记得+1!!
                                        }
                                        cout << m;
                                        return 0;
                                    }
                                    

                                    点个赞👍 吧😄

                                    信息

                                    ID
                                    1292
                                    时间
                                    1000ms
                                    内存
                                    256MiB
                                    难度
                                    3
                                    标签
                                    递交数
                                    8047
                                    已通过
                                    4117
                                    上传者