Submission #27857443


Source Code Expand

#include <iostream>
#include <string>
#include <vector>

using u32 = unsigned int;
using u64 = unsigned long long int;

int main(){
  u64 n, x;
  std::cin >> n >> x;
  std::vector<u64> a(n);
  for(u32 i = 0; i < n; i++) std::cin >> a[i];
  
  for(u32 i = 0; i < n-1; i++) a[i] = a[i+1] / a[i];

  u64 P1 = 0;
  u64 P0 = 1;

  u32 l = 0;

  while(l < n-1){
    u64 k = x % a[l];
    u64 PP0 = (k!=a[l]-1)*P1 + P0;
    P1 = P1 + (k>0)*P0;
    P0 = PP0;
    x /= a[l++];
  }

  std::cout << (P0 + P1) << std::endl;

  return 0;
}

Submission Info

Submission Time
Task F - Valid payments
User ryuhei
Language C++ (GCC 9.2.1)
Score 600
Code Size 559 Byte
Status AC
Exec Time 7 ms
Memory 3620 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 4
AC × 35
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All answer_big_00.txt, border_00.txt, border_01.txt, border_02.txt, border_03.txt, border_04.txt, border_05.txt, border_06.txt, border_07.txt, border_08.txt, border_09.txt, handmade_00.txt, handmade_01.txt, handmade_02.txt, handmade_03.txt, longest_00.txt, longest_01.txt, longest_02.txt, longest_03.txt, longest_04.txt, overflow_killer_00.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Case Name Status Exec Time Memory
answer_big_00.txt AC 7 ms 3444 KiB
border_00.txt AC 3 ms 3556 KiB
border_01.txt AC 2 ms 3592 KiB
border_02.txt AC 3 ms 3448 KiB
border_03.txt AC 2 ms 3596 KiB
border_04.txt AC 2 ms 3384 KiB
border_05.txt AC 5 ms 3512 KiB
border_06.txt AC 2 ms 3600 KiB
border_07.txt AC 2 ms 3612 KiB
border_08.txt AC 2 ms 3608 KiB
border_09.txt AC 2 ms 3392 KiB
handmade_00.txt AC 2 ms 3568 KiB
handmade_01.txt AC 2 ms 3508 KiB
handmade_02.txt AC 2 ms 3444 KiB
handmade_03.txt AC 3 ms 3420 KiB
longest_00.txt AC 2 ms 3420 KiB
longest_01.txt AC 2 ms 3620 KiB
longest_02.txt AC 2 ms 3392 KiB
longest_03.txt AC 2 ms 3600 KiB
longest_04.txt AC 2 ms 3552 KiB
overflow_killer_00.txt AC 2 ms 3600 KiB
random_00.txt AC 1 ms 3388 KiB
random_01.txt AC 2 ms 3608 KiB
random_02.txt AC 2 ms 3384 KiB
random_03.txt AC 2 ms 3612 KiB
random_04.txt AC 2 ms 3512 KiB
random_05.txt AC 2 ms 3604 KiB
random_06.txt AC 2 ms 3388 KiB
random_07.txt AC 4 ms 3600 KiB
random_08.txt AC 2 ms 3596 KiB
random_09.txt AC 2 ms 3592 KiB
sample_01.txt AC 2 ms 3604 KiB
sample_02.txt AC 2 ms 3452 KiB
sample_03.txt AC 3 ms 3512 KiB
sample_04.txt AC 2 ms 3592 KiB