You are playing a game which you will battle with an enemy. As you don’t want to lose, your total power can’t be lower than your enemy’s. Your power is simply added by the power of your soldiers, and all of your soldiers’ power is exactly aa. Now you have known that your enemy’s total power is bb. You want to know how many soldiers you need in order not to lose the battle.
Input:
A line with two integers a,ba,b, (1≤a,b≤109)(1≤a,b≤109).
Output:
A line with one integer, denotes the minimum number of soldiers you need.
Sample Input:
1
123 456
Sample Output:
1
4
AC代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include<iostream>
usingnamespacestd;
intmain(){ int a, b; while(cin >> a>> b){ int ans=1; if ( b%a != 0) ans= b/a+1; // cout << b/a+1<< endl; else ans = b/a; // cout << b/a << endl; cout << ans << endl; } return0; }
Alice and Bob are playing a game called Gomoku (a.k.a. Five in a Row). Alice is sente(black, moves first) and Bob is gote(white, moves second). Alice wants to know whether she can win(have five or more consecutive stones of the same color in a diagonal, vertical, or horizontal row) in one step, and now is Alice’s turn. It is guranteed that neither Alice or Bob wins currently. Prohibitions are not considered in this problem.
Input:
The first line contains one integer nn, which denotes the size of the board is n×nn×n.
Next nn lines each has a string of length nn, use @ to represent black, O to represent white, + to represent there’s no stone at that position.
Output:
If Alice can win in one step, output YES, otherwise output NO.
publicclassMain{ publicstaticintsolve(int n){ BigInteger res = new BigInteger("1"); for(int i=1;i<=n;i++){ BigInteger tmp = new BigInteger(String.valueOf(i)); res = res.multiply(tmp); } // System.out.printf("%s\n",res.bitCount()); // System.out.printf("%s\n",res.bitLength()); // System.out.printf("%d\n",res.byteValue()); String s = res.toString(); int ans = 0; for(int j=s.length()-1;j>=0;j--){ if (s.charAt(j)=='0') ans ++; elsebreak; } return ans; } publicstaticvoidmain(String[] args){ Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); System.out.printf("%d",solve(n)); }