Skip to content

0721_safe_Kang040429.c #984

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions 0722_2_Kang040429.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <stdio.h>

int main() {

int t = 0;
int max = 0;
int n[100000];

scanf("%d", &t);

for (int i = 0; i < t; i++) {

scanf("%d", &n[i]);
}

for (int i = 0; i < t; i++) {

max = n[i];

for (int j = 0; n[i] != 1; j++) {

if (n[i] % 2 == 0) {
n[i] /= 2;
}
else {
n[i]=(n[i] * 3) + 1;
}

if (max < n[i]) {
max = n[i];
}
}
printf("%d\n", max);

}

return 0;
}
45 changes: 45 additions & 0 deletions 시즌14/하/Kang040429
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include <stdio.h>

float maxAmount(float, float, float);

int main() {

float ABC[3];
float ijk[3];
float divisor = 0;
float max_product = 0;
int flag = 1;
float point = 0;


scanf("%f %f %f", &ABC[0], &ABC[1], &ABC[2]);
scanf("%f %f %f", &ijk[0], &ijk[1], &ijk[2]);

max_product = ABC[0];
for (int i = 0; i <= 2;i++) {
max_product = maxAmount(max_product, ABC[i], ijk[i]);
}

for (int i = 0; i <= 2;i++) {

ABC[i] = ABC[i]-ijk[i]*max_product;

if (ABC[i] - (int)ABC[i] < 0.00001) {

printf("%d ", (int)ABC[i]);
}
else {

printf("%f ", ABC[i]);
}
}
}

float maxAmount(float a, float c, float d) {
if (a < c/d) {
return a;
}
else {
return c/d;
}
}