QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#602156#7809. 小苹果tiankonguse100 ✓0ms3908kbC++20917b2024-09-30 20:21:532024-09-30 20:21:54

Judging History

This is the latest submission verdict.

  • [2024-09-30 20:21:54]
  • Judged
  • Verdict: 100
  • Time: 0ms
  • Memory: 3908kb
  • [2024-09-30 20:21:53]
  • Submitted

answer

/*
ID: tiankonguse
TASK: apple
LANG: C++
CONTEST: CSP-J 2023
OJ: https://qoj.ac/contest/1427/problem/7809
*/
#define TASK "apple"

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

void InitIO() {
// #ifndef USACO_LOCAL_JUDGE
//   freopen(TASK ".in", "r", stdin);
//   freopen(TASK ".out", "w", stdout);
// #endif
}

/*
题目:问几天苹果可以拿完,最后一个苹果是第几天拿走的。
思路:每天拿走 1/3 个苹果, `log(n)`天拿完。

1: 1(*)
2: 1 1(*)
3: 1 1 1(*)
4: 2(*) 1 1
*/
void Solver() {  //
  ll n;
  scanf("%lld", &n);

  ll all_day = 0, n_day = 0;
  while (n) {
    all_day++;
    ll choice = 1 + (n - 1) / 3;
    if (n_day == 0 && n % 3 == 1) {
      n_day = all_day;
    }
    n -= choice;
  }

  printf("%lld %lld\n", all_day, n_day);
}

int main() {
  InitIO();
  Solver();
  return 0;
}
/*
8
5 5
*/

Details

Tip: Click on the bar to expand more detailed information

Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 0ms
memory: 3852kb

input:

5

output:

4 4

result:

ok single line: '4 4'

Test #2:

score: 10
Accepted
time: 0ms
memory: 3892kb

input:

8

output:

5 5

result:

ok single line: '5 5'

Test #3:

score: 10
Accepted
time: 0ms
memory: 3808kb

input:

713

output:

16 2

result:

ok single line: '16 2'

Test #4:

score: 10
Accepted
time: 0ms
memory: 3824kb

input:

799

output:

16 1

result:

ok single line: '16 1'

Test #5:

score: 10
Accepted
time: 0ms
memory: 3824kb

input:

747

output:

16 8

result:

ok single line: '16 8'

Test #6:

score: 10
Accepted
time: 0ms
memory: 3852kb

input:

779161

output:

33 1

result:

ok single line: '33 1'

Test #7:

score: 10
Accepted
time: 0ms
memory: 3908kb

input:

576262

output:

32 1

result:

ok single line: '32 1'

Test #8:

score: 10
Accepted
time: 0ms
memory: 3800kb

input:

782951

output:

33 4

result:

ok single line: '33 4'

Test #9:

score: 10
Accepted
time: 0ms
memory: 3844kb

input:

551877

output:

32 2

result:

ok single line: '32 2'

Test #10:

score: 10
Accepted
time: 0ms
memory: 3892kb

input:

926023422

output:

50 4

result:

ok single line: '50 4'