AtCoder Regular Contest 075

Submission #1327045

Source codeソースコード

// spagetti
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int n;
  scanf("%d",&n);
  ll ans = 0;
  for (int i = 2; i <= 18; ++i) {
    ll x = 1; rep(j,i-1) x *= 10; --x;
    ll y = 1;
    ll m = n;
    ll cnt = 1;
    bool fst = true;
    while (x >= 0) {
      if (x == 0) {
        cnt *= 10;
        break;
      }
      ll t = 0;
      while (m%(y*10)/y != (9*t)%10) ++t;
      // cerr<<i<<" "<<m<<" "<<x<<" "<<y<<" "<<t<<" "<<cnt<<endl;
      m = abs(m-x*t);
      cnt *= (fst?9:10) - t;
      x = (x-99*y)/10;
      y *= 10;
      fst = false;
    }
    if (!m) ans += cnt;
  }
  cout<<ans<<endl;
  return 0;
}




















Submission

Task問題 F - Mirrored
User nameユーザ名 ຣസںƙᘓ
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 800
Source lengthソースコード長 2920 Byte
File nameファイル名
Exec time実行時間 2 ms
Memory usageメモリ使用量 384 KB

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:73:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^

Test case

Set

Set name Score得点 / Max score Cases
Sample - a01,a02,a03
All 800 / 800 a01,a02,a03,b04,b05,b06,b07,b08,b09,b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,b21,b22,b23,b24,b25,b26,b27,b28,b29,b30,b31,b32,b33,b34,b35,b36,b37,b38,b39,b40,b41,b42,b43,b44,b45,b46,b47,b48,b49,b50,b51,b52,b53,b54,b55,b56,b57,b58,b59,b60,b61,b62,b63

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
a01 AC 1 ms 256 KB
a02 AC 1 ms 256 KB
a03 AC 1 ms 256 KB
b04 AC 1 ms 256 KB
b05 AC 1 ms 256 KB
b06 AC 1 ms 256 KB
b07 AC 1 ms 256 KB
b08 AC 1 ms 256 KB
b09 AC 1 ms 256 KB
b10 AC 1 ms 256 KB
b11 AC 1 ms 256 KB
b12 AC 1 ms 256 KB
b13 AC 1 ms 256 KB
b14 AC 1 ms 256 KB
b15 AC 2 ms 384 KB
b16 AC 1 ms 256 KB
b17 AC 1 ms 256 KB
b18 AC 1 ms 256 KB
b19 AC 1 ms 256 KB
b20 AC 1 ms 256 KB
b21 AC 1 ms 256 KB
b22 AC 1 ms 256 KB
b23 AC 1 ms 256 KB
b24 AC 1 ms 256 KB
b25 AC 1 ms 256 KB
b26 AC 1 ms 256 KB
b27 AC 1 ms 256 KB
b28 AC 1 ms 256 KB
b29 AC 1 ms 256 KB
b30 AC 1 ms 256 KB
b31 AC 1 ms 256 KB
b32 AC 1 ms 256 KB
b33 AC 1 ms 256 KB
b34 AC 1 ms 256 KB
b35 AC 1 ms 256 KB
b36 AC 1 ms 256 KB
b37 AC 1 ms 256 KB
b38 AC 1 ms 256 KB
b39 AC 1 ms 256 KB
b40 AC 1 ms 256 KB
b41 AC 1 ms 256 KB
b42 AC 1 ms 256 KB
b43 AC 1 ms 256 KB
b44 AC 1 ms 256 KB
b45 AC 1 ms 256 KB
b46 AC 1 ms 256 KB
b47 AC 1 ms 256 KB
b48 AC 1 ms 256 KB
b49 AC 1 ms 256 KB
b50 AC 1 ms 256 KB
b51 AC 1 ms 256 KB
b52 AC 1 ms 256 KB
b53 AC 1 ms 256 KB
b54 AC 1 ms 256 KB
b55 AC 1 ms 256 KB
b56 AC 1 ms 256 KB
b57 AC 1 ms 256 KB
b58 AC 1 ms 256 KB
b59 AC 1 ms 256 KB
b60 AC 1 ms 256 KB
b61 AC 1 ms 256 KB
b62 AC 1 ms 256 KB
b63 AC 1 ms 256 KB