﻿<?xml version="1.0" encoding="utf-8"?>
<feed xmlns:blogChannel="http://backend.userland.com/blogChannelModule" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:betag="https://blogengine.io/schemas/tags" xmlns="http://www.w3.org/2005/Atom">
  <id>https://robootika.com/</id>
  <title>Reaali Robootika.COM - Informaatika olümpiaadi põhikooli eelvoor – Jada seest numbri leidmine</title>
  <updated>2011-12-27T12:38:05+00:00</updated>
  <link href="https://robootika.com/" />
  <link rel="self" href="https://robootika.com/syndication.axd?format=atom" />
  <subtitle>NXT robotimaailm ja programmeerimine C-keeles</subtitle>
  <author>
    <name>Leivo</name>
  </author>
  <generator uri="https://blogengine.io/" version="1.0.0.0">BlogEngine.Net Syndication Generator</generator>
  <blogChannel:blogRoll>https://robootika.com/opml.axd</blogChannel:blogRoll>
  <dc:creator>Leivo</dc:creator>
  <dc:description>NXT robotimaailm ja programmeerimine C-keeles</dc:description>
  <dc:language>en-US</dc:language>
  <dc:title>Reaali Robootika.COM</dc:title>
  <geo:lat>0.000000</geo:lat>
  <geo:long>0.000000</geo:long>
  <entry>
    <id>https://robootika.com/post/Informaatika-olumpiaadi-eelvoor-2011-pohikool-ulesanne-3#id_10c9e005-1af8-4a96-8564-22b0f628833b</id>
    <title>Simmo on &lt;a href="/post/Informaatika-olumpiaadi-eelvoor-2011-pohikool-ulesanne-3#id_10c9e005-1af8-4a96-8564-22b0f628833b" alt="/post/Informaatika-olumpiaadi-eelvoor-2011-pohikool-ulesanne-3#id_10c9e005-1af8-4a96-8564-22b0f628833b"&gt;Informaatika olümpiaadi põhikooli eelvoor – Jada seest numbri leidmine&lt;/a&gt;</title>
    <updated>2011-12-27T12:38:05+00:00</updated>
    <link rel="self" href="https://robootika.com/post/Informaatika-olumpiaadi-eelvoor-2011-pohikool-ulesanne-3#id_10c9e005-1af8-4a96-8564-22b0f628833b" />
    <link href="https://robootika.com/post/Informaatika-olumpiaadi-eelvoor-2011-pohikool-ulesanne-3#id_10c9e005-1af8-4a96-8564-22b0f628833b" />
    <author>
      <name>Simmo</name>
    </author>
    <summary type="html">Ei s&amp;#252;venenud v&amp;#228;ga su lahendusse, kuid see for loop on k&amp;#252;ll hirmu&amp;#228;ratav. Lisaks tundub mulle, et see programm ei v&amp;#228;ljasta &amp;#245;iget tulemust: programm v&amp;#228;ljastab tulemus ja tulemus+1, kuid k&amp;#252;siti hoopis numbrit N ja N+1 &lt;strong&gt;positsioonil&lt;/strong&gt;, mitte &amp;#252;he v&amp;#245;rra suuremat (n&amp;#228;ited on petlikud).

Minu C++ lahendus, mis sai maksimumi, oli selline:  (code tagi ka kuidagi saab kommentaaris?)
&lt;cite title="Quote"&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;fstream&amp;gt;
#include &amp;lt;sstream&amp;gt;
#include &amp;lt;cmath&amp;gt;

using namespace std;

// arvuta mitu symbolit on vastava jargu arvudel kokku
unsigned int astesym(int aste)
{
    return 9 * pow(10.0, aste) * (aste + 1);
}

int main()
{
    ifstream fin(&amp;quot;jada.sis&amp;quot;);
    ofstream fout(&amp;quot;jada.val&amp;quot;);
    
    unsigned int N;
    fin &amp;gt;&amp;gt; N;
    
    // vahenda arvu, leia jark
    int aste = 0;
    for (; N &amp;gt; astesym(aste); aste++)
    {
        N -= astesym(aste);
    }
    
    // sea loendamise alguseks 0; 1 asemel
    N--;
    
    // leia arv milles N on ja mitmes number (i)
    unsigned int num = pow(10.0, aste) + N / (aste + 1);
    unsigned int i = N % (aste + 1);
    
    // tekstina num ja sellest jargmine(kui i peaks ule minema)
    stringstream ss;
    ss &amp;lt;&amp;lt; num &amp;lt;&amp;lt; num + 1;
    string str = ss.str();
    
    fout &amp;lt;&amp;lt; str[i] &amp;lt;&amp;lt; str[i + 1] &amp;lt;&amp;lt; endl;
    
    return 0;
}&lt;/cite&gt;</summary>
    <published>2011-12-27T12:38:05+00:00</published>
    <link rel="related" href="https://robootika.com/post/Informaatika-olumpiaadi-eelvoor-2011-pohikool-ulesanne-3#id_10c9e005-1af8-4a96-8564-22b0f628833b#comment" />
    <dc:publisher>Simmo</dc:publisher>
    <pingback:server>https://robootika.com/pingback.axd</pingback:server>
    <pingback:target>https://robootika.com/post/Informaatika-olumpiaadi-eelvoor-2011-pohikool-ulesanne-3#id_10c9e005-1af8-4a96-8564-22b0f628833b</pingback:target>
    <wfw:comment>https://robootika.com/post/Informaatika-olumpiaadi-eelvoor-2011-pohikool-ulesanne-3#id_10c9e005-1af8-4a96-8564-22b0f628833b#comment</wfw:comment>
    <wfw:commentRss>https://robootika.com/syndication.axd?post=10c9e005-1af8-4a96-8564-22b0f628833b</wfw:commentRss>
  </entry>
  <entry>
    <id>https://robootika.com/post/Informaatika-olumpiaadi-eelvoor-2011-pohikool-ulesanne-3#id_c9d98405-1a8d-4342-b41d-8510c446ad76</id>
    <title>Leivo on &lt;a href="/post/Informaatika-olumpiaadi-eelvoor-2011-pohikool-ulesanne-3#id_c9d98405-1a8d-4342-b41d-8510c446ad76" alt="/post/Informaatika-olumpiaadi-eelvoor-2011-pohikool-ulesanne-3#id_c9d98405-1a8d-4342-b41d-8510c446ad76"&gt;Informaatika olümpiaadi põhikooli eelvoor – Jada seest numbri leidmine&lt;/a&gt;</title>
    <updated>2011-12-27T13:35:06+00:00</updated>
    <link rel="self" href="https://robootika.com/post/Informaatika-olumpiaadi-eelvoor-2011-pohikool-ulesanne-3#id_c9d98405-1a8d-4342-b41d-8510c446ad76" />
    <link href="https://robootika.com/post/Informaatika-olumpiaadi-eelvoor-2011-pohikool-ulesanne-3#id_c9d98405-1a8d-4342-b41d-8510c446ad76" />
    <author>
      <name>Leivo</name>
    </author>
    <summary type="html">Suurep&amp;#228;rane.
See loop tundus ka mulle endale &amp;#252;sna hirmu&amp;#228;ratav &lt;img src="/admin/editors/tinymce/plugins/emoticons/img/smiley-smile.gif" class="flag" alt="Smile" /&gt;
T&amp;#228;nud selle korrektse lahenduse jagamise eest!</summary>
    <published>2011-12-27T13:35:06+00:00</published>
    <link rel="related" href="https://robootika.com/post/Informaatika-olumpiaadi-eelvoor-2011-pohikool-ulesanne-3#id_c9d98405-1a8d-4342-b41d-8510c446ad76#comment" />
    <dc:publisher>Leivo</dc:publisher>
    <pingback:server>https://robootika.com/pingback.axd</pingback:server>
    <pingback:target>https://robootika.com/post/Informaatika-olumpiaadi-eelvoor-2011-pohikool-ulesanne-3#id_c9d98405-1a8d-4342-b41d-8510c446ad76</pingback:target>
    <wfw:comment>https://robootika.com/post/Informaatika-olumpiaadi-eelvoor-2011-pohikool-ulesanne-3#id_c9d98405-1a8d-4342-b41d-8510c446ad76#comment</wfw:comment>
    <wfw:commentRss>https://robootika.com/syndication.axd?post=c9d98405-1a8d-4342-b41d-8510c446ad76</wfw:commentRss>
  </entry>
</feed>