Last active
January 30, 2020 11:14
-
-
Save kerolloz/5ffa716a772c568a9be1589dd947486e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main () { | |
long long n, m; | |
scanf("%lld %lld", &n, &m); | |
const long long MOD = 17e7; // same as 17x10^7 | |
long long ans = m; | |
// or ans = 1 and for(int i = 0; i < n; i++) | |
for(int i = 1; i < n; i++) { | |
ans = (ans * m) % MOD; | |
} | |
printf("%lld\n", ans); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
int n; | |
scanf("%d", &n); | |
double wait[n]; // one of (wait or burst) must be double "because int division => int" | |
int burst[n]; | |
double max_response_time = 0; | |
for (int i = 0; i < n; i++) | |
scanf("%lf", &wait[i]); | |
for (int i = 0; i < n; i++) | |
{ | |
scanf("%d", &burst[i]); | |
double process_response_time = (wait[i] + burst[i]) / burst[i]; | |
if (process_response_time > max_response_time) | |
max_response_time = process_response_time; | |
} | |
printf("%.6f\n", max_response_time); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
int n; | |
cin >> n; | |
int form2[n];/// order of questions in form2 | |
for(int i = 0; i < n; i++) | |
cin >> form2[i]; | |
char answer[n];/// answers of questions from 1-n | |
/// note array index from 0 -> n-1 which means answer[0] is question 1 | |
for(int i = 0; i < n; i++) | |
cin >> answer[i]; | |
for(int i = 0; i < n; i++){/// loop on form2 questions | |
int current_question = form2[i]; | |
char current_answer = answer[current_question - 1];/// -1 to make it zero based | |
cout << current_answer << " "; | |
} | |
return 0; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int score (int n){ | |
int number_of_operations = 0; | |
while(n != 1){ | |
if(n % 2 == 0) { | |
n /= 2; | |
}else { | |
n = 3 * n + 1; | |
} | |
number_of_operations++; | |
} | |
return number_of_operations; | |
} | |
int main () { | |
int r, k; | |
scanf("%d %d", &r, &k); | |
int rokaia_score = score(r); | |
int koko_score = score(k); | |
if(rokaia_score >= koko_score) | |
printf("Rokaia wins!\n"); | |
else | |
printf("Koko wins!\n"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main () { | |
char x, y; | |
scanf("%c %c", &x, &y); // cin >> x >> y; | |
printf("%c%c\n", x, y); // cout << x << y << endl; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main () { | |
int n; | |
scanf("%d", &n); | |
char students[n][106]; | |
// 106 because the max length of the name is 105 "don't forget the null char" | |
// or You can use "string studnets[n];" in C++ | |
for(int i = 0; i < n; i++) | |
scanf("%s", students[i]); | |
for(int i = n-1; i >= 0; i--) | |
printf("%s\n", students[i]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment