[Logo] Mendo Judge Discussion Board - Forums
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
Messages posted by: Hakun
Forum Index » Profile for Hakun » Messages posted by Hakun
Author Message
За уште побрзо извршување почнете со итерирање од најголемиот кон најмалиот [code]
#include <bits/stdc++.h>

using namespace std;

int main()
{
int n; cin>>n;
int sticks[10]={6,3,5,5,4,5,5,3,7,5};

for(int i = 9999; i>=1000;i--)
{
int used =0;
int temp = i;
while(temp>0)
{
int digit = temp%10;
temp/=10;
used+=sticks[digit];
}
if(used==n)
{
cout<<i; return 0;
}
}
cout<<-1;
return 0;
}
 
Forum Index » Profile for Hakun » Messages posted by Hakun
Go to:   
Powered by JForum 2.1.8 © JForum Team