RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0700

Strange Function

Bronze II 브론즈 II
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

For all positive integers \(x\), the function \(f(x)\) is defined as follows:

  • If \(x\) has any digits that aren't \(0\) or \(1\), for each digit of \(x\), set it to \(1\) if it is odd or \(0\) otherwise, and return \(x\).
  • Otherwise, return \(x-1\).

Given a value of \(x\) (\(1 \leq x < 10^{2\cdot 10^5}\)), find how many times \(f\)
needs to be applied to \(x\) until \(x\) reaches \(0\). As this number might be very
large, output its remainder when divided by \(10^9+7\).

Problem credits: Aidan Bai

제약

SCORING

  • Inputs 3-5: \(T\le 2000\), \(x< 10^{9}\)
  • Inputs 6-7: \(x<10^{18}\)
  • Inputs 8-9: \(x<10^{60}\)
  • Inputs 10-12: No additional constraints.

Problem credits: Aidan Bai

입력 형식

The first line contains \(T\) (\(1\le T\le 10^5\)), the number of independent tests.

The next \(T\) lines each contain a positive integer \(x\) consisting solely of the
digits 0-9, with no leading zeros.

It is guaranteed that the total number of digits in all input integers does not
exceed \(10^6\).

출력 형식

For each test case, output the remainder of the number of times when divided by
\(10^9+7\) on a separate line.

예제 1
입력
2
24680
210
출력
1
4
설명

First test: \(x\) becomes zero after one operation.

Second test: \(f(x)=10, f^2(x)=9, f^3(x)=1, f^4(x)=0\)

예제 2
입력
1
1234567890123456789012345678901234567890
출력
511620083
문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2025-2026 > Third Contest > Bronze

태그

평가 및 의견

Strange Function

개요
출제자 난이도 Bronze II 브론즈 II 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Strange Function

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8