-
Notifications
You must be signed in to change notification settings - Fork 1
10-froglike6 #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
10-froglike6 #42
Conversation
hadongun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ²μ λ³΄κ³ κ·Έλ₯ forλ¬ΈμΌλ‘ νλ € νλλ°.. X λ²μλ₯Ό 보λ μκ° μ΄κ³Όκ° λ κ² λ»ν κ² κ°λκ΅°μ..!
μ΄λΆ νμμΌλ‘ νμ΄ λ΄€λλ°, μμ§ μ΅μνμ§ μμμ μκ°μ΄ μ’ κ±Έλ¦¬λ€μ©
νμ΄μ¬μΌλ‘ νμ΄λ΄€μ΄μ₯
νμ΄ν
import sys
left = 1
right = 1000000000
x, y = map(int, input().split())
Z = (y*100)//x
answer = -1
def condition(mid):
return ((y + mid) * 100) // (x + mid) > Z
if Z >= 99:
print(-1)
sys.exit()
while left <= right:
mid = (left + right)//2
if condition(mid):
answer = mid
right = mid -1
else:
left = mid + 1
print(answer)
dohyeondol1
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
λ³΄κ³ μ΄λΆνμμΌλ‘ νμ΄μΌκ² λ€λ μκ°μ λ€μλλ°...
λ²μλ₯Ό μ΄λ»κ² μ‘μμΌ νλμ§μ λν΄μ νμ°Έ κ³ λ―Ό νμ΅λλ€.
λλ¬΄μ§ λͺ¨λ₯΄κ² μ΄μ κ·Έλ₯ μ΅λκ°μΌλ‘ μ‘κ³ νμλλ λ§μλ€μ.. γ
μ λ λΌμ΄λΈλ¬λ¦¬ ν¨μλ₯Ό μ¬μ©νλκ² μλλΌλ©΄ 컀μ€ν
ν¨μλ‘ λ§λ€μ΄ μ°λ νΈμΈλ°,
λνλ μ½λλ₯Ό 보λ κ΅³μ΄ ν¨μλ‘ κ΅¬ννμ§ μμλλΌλ ν μ μμμ κ±°λΌλ μκ°μ΄ λλ€μ.
C++
#include <iostream>
using namespace std;
long long binary_search(long long gameCount, long long winCount) {
long long currentRate = 100*winCount/gameCount;
long long result = -1;
long long left = 0, right = 1e9;
while(left <= right) {
long long mid = (left+right)/2;
long long newWinRate = 100*(winCount+mid)/(gameCount+mid);
if(newWinRate > currentRate) {
result = mid;
right = mid-1;
}
else left = mid+1;
}
return result;
}
int main() {
long long X, Y, Z;
cin >> X >> Y;
Z = 100*Y/X;
if(Z >= 99) {
cout << -1 << '\n';
return 0;
}
long long minCount = binary_search(X, Y);
cout << minCount << '\n';
return 0;
}
caucsejunseo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ΄λΆνμμ΄ μμ§ μ΄μν΄μ λ°λ‘λ°λ‘ λ μ€λ₯΄μ§ μλ€μ. μμ κ³μ°μ μ€λλ§μ ν΄λ΄μ Z = (Y / X)*100; μ΄λ° μμΌλ‘ νλ€κ° μ€λ ν€λ§Έλ€μ
μ¨
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
int main() {
long long X, Y;
scanf("%lld %lld", &X, &Y);
long long Z = (Y * 100) / X;
if (Z >= 99) {
printf("-1\n");
return 0;
}
long long left = 1;
long long right = 1000000000;
long long result = -1;
while (left <= right) {
long long mid = (left + right) / 2;
long long newZ = ((Y + mid) * 100) / (X + mid);
if (newZ > Z) {
result = mid;
right = mid - 1;
}
else {
left = mid + 1;
}
}
printf("%lld\n", result);
return 0;
}
π λ¬Έμ λ§ν¬
κ²μ
βοΈ μμλ μκ°
20λΆ
β¨ μλ μ½λ
μλ μ½λ
μ΄ λ¬Έμ λ μ£Όμ΄μ§ κ²μ νμ Xμ μ΄κΈ΄ κ²μμ νμ Yκ° μ£Όμ΄μ‘μ λ, μΉλ₯ μ μ μ λΆλΆμ΄ λ°λκΈ° μν΄μ λͺ νμ λ μ΄κ²¨μΌ νλμ§ κ΅¬νλ λ¬Έμ μ λλ€.
X=53μ΄κ³ , Y=47μ΄λ©΄ (47/53)*100=88....μ΄λ―λ‘ Z=88μ΄ λ©λλ€. μ¬κΈ°μ Zκ° λ°λκΈ° μν μλ₯Ό μ§μ μ°Ύλ κ²μ μ€λ 걸리λ―λ‘, μ΄λΆ νμμ μ¬μ©νμ΅λλ€. μλ‘μ΄ μΉλ₯ Z`=((Y + mid) * 100) // (X + mid)μ΄ λ°λλ μ΅μ midλ₯Ό μ°Ύλ μ΄λΆ νμμ ν΅ν΄ λ¬Έμ λ₯Ό ν΄κ²°νμ΅λλ€.
π μλ‘κ² μκ²λ λ΄μ©