zoukankan      html  css  js  c++  java
  • e-olymp Problem4196 Chocolate bars

    吐槽一下,这个OJ的题目真的是阅读理解题。代码非常短,就是题目难理解。心累。

    传送门:点我

    Chocolate bars

    It is hard to overestimate the role of chocolate bars in traditional programming competitions. Firstly, the nutritional content of chocolate significantly increases the number of brilliant ideas among the participants of the Olympiad. Geometric shape of the tiles is usually a rectangle of size a × b of square pieces 1 × 1, which in turn recalls the model of many problems.

    Given the size of one chocolate bar a × b and the number of Olympiad participants n. The jury members want to determine the number of enough chocolate bars, so that breaking the bars into single pieces, it will be possible to divide them equally among all n participants. That is, each participants can receive equal number of square tiles 1 × 1.

    Input

    Positive integers abn. All numbers do not exceed 100.

    Output

    Print the enough number of chocolate bars.

    Time limit 1 second
    Memory limit 128 MiB
    Input example #1
    3 5 6
    
    Output example #1
    2

    题意:输入的是a,b,n,巧克力大小为a*b,可以分成1*1的,要求给n个人分,每个人都要一样多。
       样例是,3*5*2,这样就能分成30个1*1,能给6个人均分。而15个1*1则不行。
    思路:非常非常没意思的题,直接暴力枚举(a*b*i)%n 是否等于0就行,i每次加一。还是读题不太好玩。
    代码:
    #include <cstdio>
    #include <iostream>  
    using namespace std; 
    int main()
    {
        int a,b,n,k = 1;
        cin>>a>>b>>n;
        int ans = a*b,sum = a*b;
        while(ans%n){
            k++;
            ans+=sum;
        }
        printf("%d
    ",k);
    }
  • 相关阅读:
    Linux安装oracle 10g常见问题之——ORA-01078,LRM-00109,ORA-01102
    Linux安装oracle 10g常见问题之——OUI-25031
    C#中static静态变量的用法
    让DIV中的内容水平和垂直居中
    json对象与json字符串互换
    AJAX请求 $.post方法的使用
    .NET(c#)new关键字的三种用法
    创建数据库和表的SQL语句
    SQL、LINQ、Lambda 三种用法(转)
    AJAX中UPDATEPANEL配合TIMER控件实现局部无刷新
  • 原文地址:https://www.cnblogs.com/Esquecer/p/9056655.html
Copyright © 2011-2022 走看看