Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- void main() {
- short int n, p;
- int a, min, c1, c2;
- bool x = false;
- ifstream f("date.in");
- ofstream g("date.out");
- f >> n;
- for (short int i = 1; i <= n; i++) {
- f >> a;
- if (i == 1) c1 = a;
- if (i == 2) c2 = a;
- if (a % 2 && !x) {
- x = true;
- min = a;
- p = i;
- }
- if (x && a % 2 && a < min) {
- min = a;
- p = i;
- }
- }
- g << min << ' ' << p << endl;
- if (!c1 && !c2)
- g << 0;
- else
- if (!c1 && c2)
- g << c2;
- else
- if (c1 && !c2)
- g << c1;
- else {
- while (c1 != c2) {
- if (c1 > c2)
- c1 -= c2;
- else
- c2 -= c1;
- }
- g << c1;
- }
- f.close();
- g.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement