这道题比较简单,只要求出牛牛吃的蛋挞个数和b个人中每个人吃的蛋挞数量,比较一下 即可
#include <iostream>
using namespace std;
int main()
{
long long a,b,i,x,y;
cin >> a >> b;
for(i=1;b*i<=a;i++);
x=a-((i-1)*b);//牛牛吃的
y=i-1;//b个人中每个人吃的
if(x>y)
cout << "niuniu eats more than others" << endl;
else if(x<y)
cout << "niuniu eats less than others" << endl;
else
cout << "same" << endl;
}
import java.util.* ;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in) ;
long a = sc.nextLong() ;
long b = sc.nextLong() ;
long c = a / b ; //每人分多少个蛋挞
long m = a - b * c ;//牛子吃的蛋挞
if(c > m)
System.out.println("niuniu eats less than others") ;
else if(c < m)
System.out.println("niuniu eats more than others") ;
else
System.out.println("same") ;
}
}
}